blob: 01acb80ff9e38ec54f39ee1871ad9c9c0d1d3158 [file] [log] [blame]
// PR c++/103912
// { dg-do run { target c++20 } }
// { dg-additional-options "-O2 -g -fkeep-inline-functions" }
extern "C" void abort ();
struct A { A () {} };
consteval auto
foo ()
{
if (1)
;
return [] (A x) { return 1; };
}
consteval auto
bar (int a)
{
int b = a + 4;
if (1)
;
return [=] (A x) { return a + b; };
}
int
main ()
{
A x;
auto h = foo ();
if (h (x) != 1)
abort ();
auto i = bar (5);
if (i (x) != 14)
abort ();
auto j = bar (42);
if (j (x) != 88)
abort ();
}