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

--- Comment #6 from Stephan Bergmann <sberg.fun at gmail dot com> ---
While the original reproducer from comment 0 appears to be fixed in recent GCC
14 trunk, a slight modification still fails at least with recent GCC 14 trunk:

> $ cat test.cc
> struct S1 {
>   int a;
>   consteval S1(int n): a(n) {}
> };
> struct S2 {
>   S1 x;
>   S2(): x(0) {}
> };

> $ g++ -fsyntax-only -std=c++20 test.cc
> test.cc: In constructor ‘S2::S2()’:
> test.cc:7:11: error: call to consteval function 
> ‘((S2*)this)->S2::x.S1::S1(0)’ is not a constant expression
>     7 |     S2(): x(0) {}
>       |           ^~~~
> test.cc:7:11:   in ‘constexpr’ expansion of ‘((S2*)this)->S2::x.S1::S1(0)’
> test.cc:3:26: error: modification of ‘*(S2*)this’ is not a constant expression
>     3 |     consteval S1(int n): a(n) {}
>       |                          ^~~~

Reply via email to