This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/4131] The C++ compiler doesn't place a const class object to ".rodata" section with non trivial constructor
- From: "jason at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 25 Jun 2018 17:37:01 +0000
- Subject: [Bug c++/4131] The C++ compiler doesn't place a const class object to ".rodata" section with non trivial constructor
- Auto-submitted: auto-generated
- References: <bug-4131-4@http.gcc.gnu.org/bugzilla/>
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.