https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96994
Bug ID: 96994 Summary: Missing code from consteval constructor initializing const variable Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: sbergman at redhat dot com Target Milestone: --- At least with a local build of recent GCC 11 trunk and with gcc-c++-10.2.1-1.fc32.x86_64: > $ cat test.cc > #include <iostream> > struct S1 { > consteval S1() { i = 1; } > int i = 0; > }; > struct S2 { > constexpr S2() { i = 1; } > int i = 0; > }; > S1 const s1a; > constexpr S1 s1b; > S2 const s2; > int main() { std::cout << s1a.i << ' ' << s1b.i << ' ' << s2.i << '\n'; } > $ g++ -std=c++20 test.cc > $ ./a.out > 0 1 1 The first "0" is not as expected, the following two "1" demonstrate how slight modifications of the code would lead to the expected outcome.