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

Closed
@JMazurkiewicz

Description

@JMazurkiewicz

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    c++20clang:frontendLanguage frontend issues, e.g. anything involving "Sema"conceptsC++20 concepts

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions