https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126308
Bug ID: 126308
Summary: ICE with lambda-as-template-argument
Product: gcc
Version: 16.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: zyn7109 at gmail dot com
Target Milestone: ---
I came across this example when I'm fixing a clang regression as in
https://github.com/llvm/llvm-project/issues/210346, and both the example and
the variant does crash GCC.
https://godbolt.org/z/E1MPe5fe3
template <auto V, class... Ts> // #0
constexpr auto foo =
V.template operator()<Ts...>(); // #1
template<auto P, class... Ts>
constexpr auto bar =
foo<[]<Ts...>(){ return P; }>;
int x = bar<1, int, char, unsigned>;
I'm not sure if grammar allows us to expand `Ts...` at #1 into non-type
template parameters, and FWIW clang treats #1 as a NTTP different from Ts at #0
which resulted in confusing diagnostics.
Perhaps we want to diagnose such (invalid?) lambdas before we instantiating
them.