Skip to content

Clang does not see class member in a 'requires'. #55216

Closed
@EdvinVikstrom

Description

@EdvinVikstrom

Tested with clang-trunk.
Here's the code:

template<typename T>
class Test {

public:

    static constexpr int val = 16;
    
    constexpr Test()
        requires (val == 16);
};

template<typename T>
constexpr Test<T>::Test() // error: out-of-line definition of 'Test<T>' does not match any declaration in 'Test<T>'
    requires (val == 16) // error: use of undeclared identifier 'val'
{
}

int main()
{
    Test<int> test();
    return 0;
}

I tested with GCC and it gives no errors.
Replacing val == 16 with Test<T>::val == 16 removes the 'undeclared identifier...' error but 'out-of-line...' error remains.
With no template parameters the code compiles if you write Test::val == 16.

Metadata

Metadata

Assignees

Labels

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

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions