2 // { dg-do run { target c++23 } }
6 inline constexpr int correct_result = 5 + 4 + 3 + 2 + 1;
10 auto cl0 = [](this auto&& self, int n) -> int { return n ? self(n - 1) + n : 0; };
11 auto cl1 = [](this auto const& self, int n) -> int { return n ? self(n - 1) + n : 0; };
12 auto cl2 = [](this auto self, int n) -> int { return n ? self(n - 1) + n : 0; };
13 auto cl3 = [](this auto&& self, int n) { if (!n) return 0; else return self(n - 1) + n; };
14 auto cl4 = [](this auto const& self, int n){ if (!n) return 0; else return self(n - 1) + n; };
15 auto cl5 = [](this auto self, int n) { if (!n) return 0; else return self(n - 1) + n; };
16 if (cl0(5) != correct_result) __builtin_abort ();
17 if (cl1(5) != correct_result) __builtin_abort ();
18 if (cl2(5) != correct_result) __builtin_abort ();
19 if (cl3(5) != correct_result) __builtin_abort ();
20 if (cl4(5) != correct_result) __builtin_abort ();
21 if (cl5(5) != correct_result) __builtin_abort ();