This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/14324] New: Muliiple static definitions are not unique
- From: "gary at mlbassoc dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 27 Feb 2004 16:53:26 -0000
- Subject: [Bug c++/14324] New: Muliiple static definitions are not unique
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Using gcc-3.4-20040225
If there are multiple occurrences of static variables with the same name
(different scopes of course) inside a function marked extern "C", then the
names are not mangled nor made unique. The following function demonstrates
this:
void fun1(void)
{
do { static int xyz __attribute__((unused)) = 1; } while (0);
do { static int xyz __attribute__((unused)) = 2; } while (0);
do { static int xyz __attribute__((unused)) = 3; } while (0);
}
This generates the following:
.align 2
.type _ZZ4fun1vE3xyz, @object
.size _ZZ4fun1vE3xyz, 4
_ZZ4fun1vE3xyz:
.long 1
.align 2
.type _ZZ4fun1vE3xyz_0, @object
.size _ZZ4fun1vE3xyz_0, 4
_ZZ4fun1vE3xyz_0:
.long 2
.align 2
.type _ZZ4fun1vE3xyz_1, @object
.size _ZZ4fun1vE3xyz_1, 4
_ZZ4fun1vE3xyz_1:
.long 3
.section ".text"
.align 2
.globl _Z4fun1v
Whereas the same function, marked extern "C" generates this:
.align 2
.type _ZZ4fun1vE3xyz, @object
.size _ZZ4fun1vE3xyz, 4
_ZZ4fun1vE3xyz:
.long 1
.align 2
.type xyz, @object
.size xyz, 4
xyz:
.long 2
.align 2
.type xyz, @object
.size xyz, 4
xyz:
.long 3
.section ".text"
.align 2
.globl fun1v
This of course generates an assembly error.
This used to work - at least as recently as GCC-3.3.3
--
Summary: Muliiple static definitions are not unique
Product: gcc
Version: 3.4.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: gary at mlbassoc dot com
CC: gcc-bugs at gcc dot gnu dot org
GCC host triplet: i386-linux
GCC target triplet: powerpc-eabi
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14324