blob: ba3613318e63a4cca47a1d9d6d8f8e17c4a50df3 (
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
|
// PR c++/102753
// { dg-do compile { target c++20 } }
struct S {
consteval int foo () const { return 42; }
};
constexpr S s;
int
bar ()
{
auto c = &S::foo; // { dg-error "taking address of an immediate function" }
constexpr auto d = &S::foo; // { dg-error "constant evaluation returns address of immediate function" }
static auto e = &S::foo; // { dg-error "taking address of an immediate function" }
return (s.*&S::foo) (); // { dg-error "taking address of an immediate function" }
}
constexpr auto a = &S::foo; // { dg-error "constant evaluation returns address of immediate function" }
auto b = &S::foo; // { dg-error "taking address of an immediate function" }
consteval int
baz ()
{
return (s.*&S::foo) ();
}
static_assert (baz () == 42);
|