c++/8249: Objects moved from common to BSS with -fdata-sections
rittle@labs.mot.com
rittle@labs.mot.com
Thu Oct 17 03:46:00 GMT 2002
>Number: 8249
>Category: c++
>Synopsis: Objects moved from common to BSS with -fdata-sections
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Thu Oct 17 03:46:02 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator: rittle@labs.mot.com
>Release: gcc mainline; regression from 3.2.X
>Organization:
>Environment:
Seen on both i386-*-freebsd4.7 and
alpha-*-freebsd5.7 while working on libstdc++-v3
which uses -fdata-sections by default (on some platforms).
>Description:
>How-To-Repeat:
Run:
g++ -c t2.ii
nm -C t2.o
00000000 T double_bar()
00000008 C guard variable for foo<0>::bar()::double_foo
00000000 W foo<0>::fu()
00000000 W foo<0>::bar()
00000004 C foo<0>::bar()::double_foo
U __gxx_personality_v0
g++ -fdata-sections -c t2.ii
nm -C t2.o
00000000 T double_bar()
00000000 B guard variable for foo<0>::bar()::double_foo
00000000 W foo<0>::fu()
00000000 W foo<0>::bar()
00000000 B foo<0>::bar()::double_foo
U __gxx_personality_v0
Notice movement from common to BSS.
When linked against t.ii (which is also compiled with -fdata-sections):
# 1 "t.C"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "t.C"
template<int __inst>
struct foo
{
static int fu(void) { return 1; }
static void bar(void) { static int double_foo = fu(); }
};
int double_bar(void);
int main(void)
{
double_bar();
foo<0>::bar();
}
Produces:
t2.o(.bss._ZGVZN3fooILi0EE3barEvE10double_foo+0x0): multiple definition of `guard variable for foo<(int)0>::bar()::double_foo'
t.o(.bss._ZGVZN3fooILi0EE3barEvE10double_foo+0x0): first defined here
t2.o(.bss._ZZN3fooILi0EE3barEvE10double_foo+0x0): multiple definition of `foo<(int)0>::bar()::double_foo'
t.o(.bss._ZZN3fooILi0EE3barEvE10double_foo+0x0): first defined here
collect2: ld returned 1 exit status
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="t2.ii"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="t2.ii"
IyAxICJ0Mi5DIgojIDEgIjxidWlsdC1pbj4iCiMgMSAiPGNvbW1hbmQgbGluZT4iCiMgMSAidDIu
QyIKdGVtcGxhdGU8aW50IF9faW5zdD4Kc3RydWN0IGZvbwp7CiAgc3RhdGljIGludCBmdSh2b2lk
KSB7IHJldHVybiAxOyB9CiAgc3RhdGljIHZvaWQgYmFyKHZvaWQpIHsgc3RhdGljIGludCBkb3Vi
bGVfZm9vID0gZnUoKTsgfQp9OwoKdm9pZCBkb3VibGVfYmFyKHZvaWQpCnsKICBmb288MD46OmJh
cigpOwp9Cg==
More information about the Gcc-bugs
mailing list