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

            Bug ID: 117269
           Summary: Lambda with capture is accepted as NTTP
           Product: gcc
           Version: 14.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ddvamp007 at gmail dot com
  Target Milestone: ---

gcc compiles this code, clang rejects it

#include <iostream>
#include <type_traits>

consteval auto Make(int x) {
  return [x]{ return x; };
}

using Closure = decltype(Make(0));

template <Closure lambda>
struct S {};

S<Make(0)> s0;
S<Make(1)> s1;

int main() {
  std::cout << std::is_same_v<decltype(s0), decltype(s1)>;  // 0
}

Note: 'Closure' parameter can be replaced by simply auto

Reply via email to