This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/84810] New: [concepts][c++20] constraints of lambdas with explicit template parameters are not checked


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84810

            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 gnu.org
          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`.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]