https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92134

            Bug ID: 92134
           Summary: static constinit members incorrectly compile
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: vincent.hamp at higaski dot at
  Target Milestone: ---

The new C++20 constinit specifier currently doesn't seem to work with static
data members.

The following snippet compiles although the constructor of Value calls new.

struct Value {
  Value() : v{new int{42}} {}
  int* v;
};

struct S {
  static constinit inline Value v{};
};

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

Reply via email to