aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp2a/constinit14.C
blob: 06c4cb46722f6f4049fd7a9e0aafaac7a6f462a6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
// PR c++/92134 - constinit malfunction in static data member.
// { dg-do compile { target c++20 } }

struct Value {
  Value() : v{new int{42}} {}	// { dg-error "result of 'operator new'" "" { target implicit_constexpr } }
  int* v;
};

struct S {
  static constinit inline Value v{}; // { dg-error "variable .S::v. does not have a constant initializer|call to non-.constexpr. function" }
};

int main() { return *S::v.v; }