Bug ID: 84810
           Summary: [concepts][c++20] constraints of lambdas with explicit
                    template parameters are not checked
           Product: gcc
           Version: 8.0.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot
          Reporter: eric.niebler at gmail dot com
  Target Milestone: ---

The following code declares a C++20 lambda with a constraint. The invocation of
the lambda should be ill-formed unless the constraint is satisfied; however,
gcc is accepting invalid code.

template <class> constexpr bool is_int = false;
template <> constexpr bool is_int<int> = true;

template <class T>
concept bool Int = is_int<T>;

int main() {
    auto x = []<Int T>(T t) { return 42; };
    auto y = x(42);
    auto z = x(""); // should be ill-formed.
    return z;

Compile with gcc trunk and `-fconcepts -std=gnu++2a`.

Reply via email to