https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94772
Bug ID: 94772 Summary: [10 Regression] constructing constexpr variables fail with delegated constexpr constructors Product: gcc Version: 10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: gcc-bugs at marehr dot dialup.fu-berlin.de Target Milestone: --- Hi gcc! The following code does not compile with gcc10 anymore: ```c++ struct foo { constexpr foo() noexcept = default; // fails with gcc10; commenting : foo{} out works with gcc10 constexpr foo(int a, int b) : foo{} { bar += a + b; } int bar{}; }; int main() { constexpr foo bar{1, 2}; } ``` https://godbolt.org/z/brsFdo All major compilers and gcc < 10 do support this, so I think this is a regression. ``` > g++-git -std=c++2a <source>: In function 'int main()': <source>:15:27: in 'constexpr' expansion of 'foo(1, 2)' <source>:8:13: error: modifying a const object '((foo*)this)->foo::bar' is not allowed in a constant expression 8 | bar += a + b; | ~~~~^~~~~~~~ <source>:15:19: note: originally declared 'const' here 15 | constexpr foo bar{1, 2}; | ``` Thank you!