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

--- Comment #5 from Wolfgang Roehrl <wolfgang.roe...@gi-de.com> ---
Hello,

I just came back from holidays and I read your comments on my bug report. For
two reasons I still think that the compiler should not use dynamic
initialization for objX - at least not without any warning:

a) According to my understanding the Standard requests static initialization
   for a class-type variable whose constexpr constructor is invoked with
   constant expressions (cf. C++17 Standard, 6.6.2/2;); and it is additionally
   required that all sub-objects of the variable can also be initialized
statically.
   But I don't see that the Standard requests that the ctor definition has to
   precede the variable definition in order to get static initialization.

b) The behaviour of the compiler ist not user-friendly:
   A program may rely on the static initialization of an object - especially if
   the object contains atomic variables. Now somebody may modify the programm
   and move the constructor definition unintentionally behind the definiton of
   the object. The program still compiles but the program behaviour has
   changed silently and to fix this kind of bugs can be very time-consuming.


With kind regards,
W. Roehrl

Reply via email to