Skip to content

[clang-18 regression] Compile error in out-of-line definition of constrained class template nested in a class template #102320

Open
@ozaktash

Description

@ozaktash

The following code doesn't compile on Clang 18 and further:

template<typename>
concept Constrained = true;

template <typename T>
class C
{
    template<Constrained>
    class D;
};

template <typename T>
template <Constrained>
class C<T>::D
{
};

With the following message:

<source>:12:11: error: type constraint differs in template redeclaration
   12 | template <Constrained>
      |           ^
<source>:7:14: note: previous template declaration is here
    7 |     template<Constrained>
      |              ^
1 error generated.

It compiles with Clang 17, GCC and MSVC (https://godbolt.org/z/r65o8sPjs).

Metadata

Metadata

Assignees

Labels

clang:frontendLanguage frontend issues, e.g. anything involving "Sema"conceptsC++20 conceptsconfirmedVerified by a second partydiverges-from:edgDoes the clang frontend diverge from edg compilerdiverges-from:gccDoes the clang frontend diverge from gcc on this issuediverges-from:msvcDoes the clang frontend diverge from msvc on this issueregression:18Regression in 18 release

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions