Skip to content

NTTP references in requires clauses #68885

@cor3ntin

Description

@cor3ntin

Clang rejects this code

#include <concepts> 
template <decltype(auto) a>
struct S {
    static constexpr int i = 42;
};

template <decltype(auto) a>
requires true
struct S<a> {
    static constexpr int i = 0;
};

static constexpr int a = 0;

void test() {
    static_assert(S<a>::i == 0);  // Ok
    static_assert(S<(a)>::i == 0); // Fails
}

https://godbolt.org/z/hsb4c5WE3

Clang picks the primary template when a NTTP is a reference type, even if there is a more constrained specialization.
Other compiler accept this code.

Metadata

Metadata

Assignees

Labels

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

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions