Debian Codegraph @

gcc/testsuite/g++.dg/cpp2a/constexpr-lifetime2.C

raw
1 // { dg-do compile { target c++20 } }
2
3 #include "construct_at.h"
4
5 struct S { int x; };
6
7 constexpr bool foo(S s, S*& p) {
8 p = &s;
9 s.~S();
10 return true;
11 }
12
13 constexpr bool bar() {
14 // This is, strictly speaking, implementation-defined behaviour;
15 // see [expr.call] p6. However, in all other cases we destroy
16 // at the end of the full-expression, so the below should be fixed.
17 S* p;
18 foo(S{}, p), std::construct_at(p); // { dg-bogus "destroying" "" { xfail *-*-* } }
19
20 return true;
21 }
22
23 constexpr bool x = bar();