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