gcc/testsuite/g++.dg/cpp2a/constinit14.C
raw| 1 | // PR c++/92134 - constinit malfunction in static data member. |
| 2 | // { dg-do compile { target c++20 } } |
| 3 | |
| 4 | struct Value { |
| 5 | Value() : v{new int{42}} {} // { dg-error "result of 'operator new'" "" { target implicit_constexpr } } |
| 6 | int* v; |
| 7 | }; |
| 8 | |
| 9 | struct S { |
| 10 | static constinit inline Value v{}; // { dg-error "variable .S::v. does not have a constant initializer|call to non-.constexpr. function" } |
| 11 | }; |
| 12 | |
| 13 | int main() { return *S::v.v; } |