public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/52477] New: Wrong initialization order? __attribute__((constructor)) vs static data access
@ 2012-03-04 12:50 przemoc at gmail dot com
2012-03-04 13:54 ` [Bug c++/52477] " pluto at agmk dot net
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: przemoc at gmail dot com @ 2012-03-04 12:50 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52477
Bug #: 52477
Summary: Wrong initialization order?
__attribute__((constructor)) vs static data access
Classification: Unclassified
Product: gcc
Version: 4.7.0
Status: UNCONFIRMED
Severity: major
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: przemoc@gmail.com
Created attachment 26821
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=26821
Short exemplary code showing the problem
Attached file compiles flawlessly on 4.7.0, but the output binary segfaults.
Works fine in 4.6.2 though (as expected).
Looks like a serious regression.
g++-4.7 (GCC) 4.7.0 20120304 (prerelease)
built on debian wheezy x64 with:
--enable-languages=c,c++ --prefix=/opt/gcc-4.7 --program-suffix=-4.7
svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_7-branch@184878
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/52477] Wrong initialization order? __attribute__((constructor)) vs static data access
2012-03-04 12:50 [Bug c++/52477] New: Wrong initialization order? __attribute__((constructor)) vs static data access przemoc at gmail dot com
@ 2012-03-04 13:54 ` pluto at agmk dot net
2012-03-04 14:17 ` pluto at agmk dot net
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: pluto at agmk dot net @ 2012-03-04 13:54 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52477
Pawel Sikora <pluto at agmk dot net> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |pluto at agmk dot net
--- Comment #1 from Pawel Sikora <pluto at agmk dot net> 2012-03-04 13:54:09 UTC ---
looks like .init_array vs. .ctors problem.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/52477] Wrong initialization order? __attribute__((constructor)) vs static data access
2012-03-04 12:50 [Bug c++/52477] New: Wrong initialization order? __attribute__((constructor)) vs static data access przemoc at gmail dot com
2012-03-04 13:54 ` [Bug c++/52477] " pluto at agmk dot net
@ 2012-03-04 14:17 ` pluto at agmk dot net
2012-03-04 14:24 ` przemoc at gmail dot com
2012-03-05 10:20 ` rguenth at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: pluto at agmk dot net @ 2012-03-04 14:17 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52477
--- Comment #2 from Pawel Sikora <pluto at agmk dot net> 2012-03-04 14:16:29 UTC ---
you should specify explicit initialization order to avoid gpf, e.g.:
static std::map<int, int> m __attribute__((init_priority(101)));
static void insert() __attribute__((constructor(102)));
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/52477] Wrong initialization order? __attribute__((constructor)) vs static data access
2012-03-04 12:50 [Bug c++/52477] New: Wrong initialization order? __attribute__((constructor)) vs static data access przemoc at gmail dot com
2012-03-04 13:54 ` [Bug c++/52477] " pluto at agmk dot net
2012-03-04 14:17 ` pluto at agmk dot net
@ 2012-03-04 14:24 ` przemoc at gmail dot com
2012-03-05 10:20 ` rguenth at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: przemoc at gmail dot com @ 2012-03-04 14:24 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52477
--- Comment #3 from Przemysław Pawełczyk <przemoc at gmail dot com> 2012-03-04 14:24:10 UTC ---
Thanks for solution, but...
Isn't such order obvious or isn't it at least the most widely used one? I mean
that by default static data initialization should precede
constructor-functions, no? It worked in gcc 4.6 and is there any good reason to
break it?
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/52477] Wrong initialization order? __attribute__((constructor)) vs static data access
2012-03-04 12:50 [Bug c++/52477] New: Wrong initialization order? __attribute__((constructor)) vs static data access przemoc at gmail dot com
` (2 preceding siblings ...)
2012-03-04 14:24 ` przemoc at gmail dot com
@ 2012-03-05 10:20 ` rguenth at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-03-05 10:20 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52477
--- Comment #4 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-03-05 10:20:37 UTC ---
I think it's undefined what you relied upon.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-03-05 10:20 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-04 12:50 [Bug c++/52477] New: Wrong initialization order? __attribute__((constructor)) vs static data access przemoc at gmail dot com
2012-03-04 13:54 ` [Bug c++/52477] " pluto at agmk dot net
2012-03-04 14:17 ` pluto at agmk dot net
2012-03-04 14:24 ` przemoc at gmail dot com
2012-03-05 10:20 ` rguenth at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).