Skip to content

More specialized template is not selected in C++20 mode #73460

@Fedr

Description

@Fedr

In the following program

template <class T, T, T>
struct A { 
    static const int i = 1;
};

template <class T, T n>
struct A<T, n, n> { 
    static const int i = 2;
};

int j;
static_assert( A<int&, j, j>::i == 2, "" );

GCC selects more specialized (second) A<T, n, n> and the check succeeds, but Clang selects the first general A<class T, T, T> and static_assert fails in C++20 mode. Surprisingly it works fine in C++14 mode. Online demo: https://godbolt.org/z/P7sGcPYKE

Metadata

Metadata

Assignees

Labels

c++17clang:frontendLanguage frontend issues, e.g. anything involving "Sema"confirmedVerified by a second partyregression

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions