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

--- Comment #6 from Wolfgang Roehrl <wolfgang.roe...@gi-de.com> ---
Hi Jonathan, I would like to draw your attention to my new comment on your
answer to my bug report.

Thank you,
W. Roehrl


(In reply to Jonathan Wakely from comment #4)
> (In reply to Aliaksei Kandratsenka from comment #3)
> > constructor is defined after variable in this example. I am not sure this
> > real bug.
> 
> Agreed. If we use Clang and add its require_constant_initialization
> attribute to the variable definition it tells us:
> 
> 83428.cc:20:54: error: variable does not have a constant initializer
>  __attribute__((require_constant_initialization)) S2 objX;
>                                                      ^~~~
> 83428.cc:20:17: note: required by 'require_constant_initialization'
> attribute here
>  __attribute__((require_constant_initialization)) S2 objX;
>                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 83428.cc:12:7: note: undefined constructor 'S1' cannot be used in a constant
> expression
>     : m_tabS1()
>       ^
> 83428.cc:20:54: note: in call to 'S2()'
>  __attribute__((require_constant_initialization)) S2 objX;
>                                                      ^
> 83428.cc:3:15: note: declared here
>     constexpr S1 ();
>               ^
> 1 error generated.
> 
> 
> If the S1::S1() constructor is defined before the definition of objX then
> Clang doesn't warn and GCC doesn't use dynamic initialization.

Reply via email to