| 1 |
// { dg-do compile } |
| 2 |
// { dg-options "-std=c++2a" } |
| 3 |
|
| 4 |
consteval int foo () { return 42; } |
| 5 |
consteval auto bar () { return foo; } |
| 6 |
constexpr auto a = bar (); // { dg-error "immediate evaluation returns address of immediate function 'consteval int foo\\(\\)'" } |
| 7 |
struct S { int b; int (*c) (); }; |
| 8 |
consteval S baz () { return { 5, foo }; } |
| 9 |
consteval int qux () { S s = baz (); return s.b + s.c (); } |
| 10 |
consteval int quux () { constexpr S s = baz (); return s.b + s.c (); } // { dg-error "immediate evaluation returns address of immediate function 'consteval int foo\\(\\)'" } |
| 11 |
constexpr auto d = baz (); // { dg-error "immediate evaluation returns address of immediate function 'consteval int foo\\(\\)'" } |
| 12 |
constexpr auto e = qux (); |
| 13 |
constexpr auto f = quux (); // { dg-error "quux" } |