[Bug c++/4131] The C++ compiler doesn't place a const class object to ".rodata" section with non trivial constructor

jason at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon Jun 25 17:37:00 GMT 2018


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

--- Comment #32 from Jason Merrill <jason at gcc dot gnu.org> ---
As previously pointed out, since GCC 4.7, for many classes this is a simple
matter of adding "constexpr" to the constructor.

With the testcase for bug 84103, I notice that clang does dynamic
initialization at -O0 and static initialization at -O1.  We could do something
similar: if the optimizers know the value of a variable at the end of a global
initialization function, they could put that value into that variable
statically instead.


More information about the Gcc-bugs mailing list