https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98220
--- Comment #12 from Jonathan Wakely <redi at gcc dot gnu.org> --- (In reply to wuz73 from comment #11) > (In reply to Jonathan Wakely from comment #10) > > No it's, not a bug, because the C++ standard says the order is unspecified. > > The compiler is allowed to reorder them, and that's what happens with -flto. > > So what if I do need certain order (e.g. using libs provided by 3rd party)? You fix your code to not depend on initialization order, because the order is unspecified. For example, as I suggested in comment 8. Code that depends on a specific order is broken according to the C++ standard. Or you use non-standard extensions like __attribute__((init_priority(nnn))) to control the relative order of global constructors. > Also this floating point exception is really obscure. How can I pinpoint the > culprit? You look at the stack trace (e.g. in GDB) and see which global variable is being constructed, and which uninitialized global variable it is accessing.