blob: 01acb80ff9e38ec54f39ee1871ad9c9c0d1d3158 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
// 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 ();
}
|