Skip to content

Clang 16-rc2 regression: inherited constructor with dependent constraint #60868

@CaseyCarter

Description

@CaseyCarter

Caught this testing MSVCSTL with 16-rc2. Our implementation of std::ranges::subrange has the dependent constraint. I suspect inheriting from subrange is fairly rare, and have a workaround, so this isn't a release blocker.

Compiling this well-formed TU:

template <class> struct B {
  static constexpr bool meow = false;
};

template <class T>
struct D : B<T> {
  template <int = 42>
  D(int) requires (!B<T>::meow) {}
};

struct S : D<void> { using D::D; };

int main() { S{42}; }

with clang++ -std=c++20 -fsyntax-only diagnoses (https://godbolt.org/z/8a7Maa63e):

repro.cpp:8:20: error: substitution into constraint expression resulted in a non-constant expression
  D(int) requires (!B<T>::meow) {}
                   ^~~~~~~~~~~
repro.cpp:13:14: note: while checking constraint satisfaction for function 'D' required here
int main() { S{42}; }
             ^
repro.cpp:8:20: note: non-literal type '<dependent type>' cannot be used in a constant expression
  D(int) requires (!B<T>::meow) {}
                   ^
1 error generated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugDeprecated. Please set Type to Bug instead.c++20clang:frontendLanguage frontend issues, e.g. anything involving "Sema"conceptsC++20 conceptsregressionrejects-valid

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions