Skip to content

[Clang][concepts][regression] Construction of a class X nested in class template is ill-formed when X has class template friend with specific constraints #62290

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
JMazurkiewicz opened this issue Apr 21, 2023 · 5 comments
Labels
c++20 clang:frontend Language frontend issues, e.g. anything involving "Sema" concepts C++20 concepts

Comments

@JMazurkiewicz
Copy link
Contributor

JMazurkiewicz commented Apr 21, 2023

As in title. Repro:

template <class> struct First {
  struct Fail {
    template <bool C>
      requires C
    friend class Second;
  };
};

template <bool C>
  requires C
struct Second {};

auto x = First<void>::Fail{};

This code was well-formed until Clang-16. Build:

> E:\llvm-project\build-llvm\bin\clang.exe --version
clang version 17.0.0 (https://github.com/JMazurkiewicz/llvm-project.git 3b7d29832296b2f48869c9dbee7a5be060fef0c5)
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir: E:\llvm-project\build-llvm\bin
> E:\llvm-project\build-llvm\bin\clang.exe .\clang-reduced.cpp -std=c++20
.\clang-reduced.cpp:4:16: error: requires clause differs in template redeclaration
      requires C
               ^
.\clang-reduced.cpp:13:10: note: in instantiation of member class 'First<void>::Fail' requested here
auto x = First<void>::Fail{};
         ^
.\clang-reduced.cpp:10:12: note: previous template declaration is here
  requires C
           ^
1 error generated.

Last commit: 3b7d298
Compiler explorer: https://godbolt.org/z/d6zn9sh67
Discovered while testing ranges::adjacent_view from MSVC-STL.

@EugeneZelenko EugeneZelenko added c++20 clang:frontend Language frontend issues, e.g. anything involving "Sema" concepts C++20 concepts and removed new issue labels Apr 21, 2023
@llvmbot
Copy link
Member

llvmbot commented Apr 21, 2023

@llvm/issue-subscribers-c-20

@llvmbot
Copy link
Member

llvmbot commented Apr 21, 2023

@llvm/issue-subscribers-clang-frontend

@shafik
Copy link
Collaborator

shafik commented Apr 22, 2023

@erichkeane looks like this behavior changed between clang-15 and clang-16, it looks valid to me, wdyt?

@alexander-shaposhnikov
Copy link
Collaborator

fwiw - this one compiles with https://reviews.llvm.org/D146178

@JMazurkiewicz
Copy link
Contributor Author

Fixed in 6db007a
Compiler explorer: https://godbolt.org/z/d9nErKsYM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++20 clang:frontend Language frontend issues, e.g. anything involving "Sema" concepts C++20 concepts
Projects
Status: No status
Development

No branches or pull requests

5 participants