This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/50986] weak static data members with constant initializers emitted in .rodata, leading to segfault on startup
- From: "richard-gccbugzilla at metafoo dot co.uk" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 01 Feb 2012 21:14:35 +0000
- Subject: [Bug c++/50986] weak static data members with constant initializers emitted in .rodata, leading to segfault on startup
- Auto-submitted: auto-generated
- References: <bug-50986-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50986
--- Comment #2 from Richard Smith <richard-gccbugzilla at metafoo dot co.uk> 2012-02-01 21:14:35 UTC ---
As noted in comment#0, I believe there is no ODR violation here. Each
definition of U<S>::k consists of the same sequence of tokens, every name
refers to the same entity in both definitions, and none of the other provisions
of [basic.def.odr]p5 applies.
After some discussion, the proposed approach in clang is (roughly) to always
generate a guard variable (initialized to 1 for a statically-initialized
variable), and to put the variable and its guard variable in the same COMDAT
group. Full details are in this thread:
http://lists.cs.uiuc.edu/pipermail/cfe-dev/2011-November/018816.html