1 // PR c++/78131
2 // { dg-do compile { target c++17 } }
3 
4 template <typename TF>
f(TF)5 constexpr auto f(TF)
6 {
7     return [](auto...) constexpr { return true; };
8 }
9 
10 // Compiles and works as intended.
11 template <typename T0>
ok_0(T0)12 void ok_0(T0)
13 {
14     static_assert(f([](auto x) -> decltype(x){})(T0{}));
15 }
16 
17 // Compiles and works as intended.
18 template <typename T0>
ok_1(T0)19 void ok_1(T0)
20 {
21     constexpr auto a = f([](auto x) -> decltype(x){})(T0{});
22     if constexpr(a) { }
23 }
24 
25 // Compile-time error!
26 template <typename T0>
fail_0(T0)27 void fail_0(T0)
28 {
29     if constexpr(f([](auto x) -> decltype(x){})(T0{})) { }
30 }
31