This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/41611] New: guard variable is emitted even when the guarded symbol isn't
- From: "zsojka at seznam dot cz" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 6 Oct 2009 20:20:32 -0000
- Subject: [Bug middle-end/41611] New: guard variable is emitted even when the guarded symbol isn't
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Continuing from http://gcc.gnu.org/ml/gcc-help/2009-10/msg00087.html
When compiling the following code:
g++ test.cpp -o test.o -c -save-temps
---- test.cpp -------------
struct A {
static int Init()
{
static int &i = *new int();
return i;
}
};
-----------------------
Generated file contains symbol _ZGVZN1A4InitEvE1i (guard variable for i), but
not _ZZN1A4InitEvE1i (guarded variable i). Guard variable shouldn't be
generated in this case.
Since sometimes between 20090611 and 20090618, guard and guarded variables are
in the same section group. Linker then (may) generate file with undefined
_ZZN1A4InitEvE1i, which causes crash when this variable is accessed. (I hope I
understood things correctly)
Tested 3.3.6, 3.4.6, 4.1.2, 4.2.4, 4.3.4, 4.4.1, 4.5
Symbol is emitted everywhere, but only in 4.5 it causes crash.
--
Summary: guard variable is emitted even when the guarded symbol
isn't
Product: gcc
Version: 4.5.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: zsojka at seznam dot cz
GCC host triplet: x86_64-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41611