public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/14936] New: -fdata-sections + uninitialized template data objects = spurious link errors
@ 2004-04-13 10:11 zack at gcc dot gnu dot org
  2004-04-13 12:45 ` [Bug c++/14936] [3.4/3.3 Regression] " pinskia at gcc dot gnu dot org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: zack at gcc dot gnu dot org @ 2004-04-13 10:11 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2004-04-15  3:41 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-04-13 10:11 [Bug c++/14936] New: -fdata-sections + uninitialized template data objects = spurious link errors zack at gcc dot gnu dot org
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

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).