public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "zack at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/14936] New: -fdata-sections + uninitialized template data objects = spurious link errors Date: Tue, 13 Apr 2004 10:11:00 -0000 [thread overview] Message-ID: <20040413070205.14936.zack@gcc.gnu.org> (raw) Consider the following code fragment: template <typename T> struct S { static int i; }; template <typename T> int S<T>::i; int j = S<double>::i; When compiled normally, the variable S<double>::i is emitted as .comm _ZN1SIdE1iE,4,4 which is fine. When compiled with -fdata-sections on an ELF target, however, the same symbol is emitted in its own .bss subsection, like this: .globl _ZN1SIdE1iE .section .bss._ZN1SIdE1iE,"aw",@nobits .align 4 .type _ZN1SIdE1iE,@object .size _ZN1SIdE1iE,4 _ZN1SIdE1iE: .zero 4 This causes a multiple-definition error from the linker if two source files instantiate S<double> and are compiled with -fdata-sections. A linkonce section should be used instead, as is done if S<T>::i is initialized. -- Summary: -fdata-sections + uninitialized template data objects = spurious link errors Product: gcc Version: 3.4.0 Status: UNCONFIRMED Severity: normal Priority: P2 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: zack at gcc dot gnu dot org CC: gcc-bugs at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14936
next reply other threads:[~2004-04-13 7:02 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top 2004-04-13 10:11 zack at gcc dot gnu dot org [this message] 2004-04-13 12:45 ` [Bug c++/14936] [3.4/3.3 Regression] " pinskia at gcc dot gnu dot org 2004-04-14 22:08 ` [Bug c++/14936] [3.3/3.4 " cvs-commit at gcc dot gnu dot org 2004-04-14 22:22 ` [Bug c++/14936] [3.3 " zack at gcc dot gnu dot org 2004-04-14 23:13 ` zack at gcc dot gnu dot org 2004-04-14 23:35 ` gdr at integrable-solutions dot net 2004-04-15 2:25 ` cvs-commit at gcc dot gnu dot org 2004-04-15 5:10 ` zack at gcc dot gnu dot org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20040413070205.14936.zack@gcc.gnu.org \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).