| 1 |
// { dg-do compile } |
| 2 |
// { dg-additional-options "-std=gnu++20" } |
| 3 |
// { dg-skip-if "requires hosted libstdc++ for csetjmp and iostream" { ! hostedlib } } |
| 4 |
|
| 5 |
#include <csetjmp> |
| 6 |
#include <iostream> |
| 7 |
|
| 8 |
template <typename T> struct A { using type = int; }; |
| 9 |
template <typename F, typename... G> struct B {}; |
| 10 |
template <typename F> struct B<F> { using type = F; }; |
| 11 |
struct { |
| 12 |
template <typename... F, |
| 13 |
typename Overload = typename B<typename A<F>::type...>::type> |
| 14 |
int operator()(F...) { |
| 15 |
int iArrFld_0_0; |
| 16 |
for (int i = 7; i < 28; ++i) |
| 17 |
; |
| 18 |
int i1 = 3; |
| 19 |
try { |
| 20 |
for (int i = 7; i < 28; ++i) { |
| 21 |
for (int j = 0; j < 7; ++j) |
| 22 |
if (iArrFld_0_0 == 0) { |
| 23 |
for (int k = 0; k < 20000; ++k) |
| 24 |
std::cout << "Hello, world!" << std::endl; |
| 25 |
} |
| 26 |
jmp_buf env2; |
| 27 |
for (int i2 = 16; i2 < 350; ++i2) |
| 28 |
for (int j2 = 1; j2 < 75; ++j2) |
| 29 |
for (int k2 = 0; k2 < 16; ++k2) { |
| 30 |
int temp2 = i2 + j2 + k2; |
| 31 |
int mod2 = temp2 % 8; |
| 32 |
{ |
| 33 |
setjmp(env2) == 0; |
| 34 |
; |
| 35 |
} |
| 36 |
} |
| 37 |
} |
| 38 |
} catch (const std::exception &e) { |
| 39 |
} |
| 40 |
auto lambda = [](int x) { |
| 41 |
return [x](int y) { |
| 42 |
int z = 0; |
| 43 |
if (y > 0) |
| 44 |
z = 1; |
| 45 |
return z + x; |
| 46 |
}; |
| 47 |
}; |
| 48 |
for (int i = 0; i < 1000; ++i) { |
| 49 |
int m = 0; |
| 50 |
auto f = lambda(i); |
| 51 |
for (int j = 0; j < 100; ++j) |
| 52 |
m += f(j); |
| 53 |
i1 += m; |
| 54 |
} |
| 55 |
std::cout << "Final value of i1: " << i1 << std::endl; |
| 56 |
return 0; |
| 57 |
} |
| 58 |
} a; |
| 59 |
int main() { |
| 60 |
auto f = a([] {}); |
| 61 |
} |