This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/12401] New: G++ generates boguous weak definition of library routine


PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12401

           Summary: G++ generates boguous weak definition of library routine
           Product: gcc
           Version: 3.2.3
            Status: UNCONFIRMED
          Severity: minor
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: uddeborg at carmen dot se
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i386-redhat-linux
  GCC host triplet: i386-redhat-linux
GCC target triplet: i386-redhat-linux

When compiling some code referencing library routines, the generated object file
 contains a "W" definition of this library routine.

1.Create a file c.cc containing
  #include <stdlib.h>

  int f()
  {
    return atoi <= 0;
  }
2. g++ -O -c c.cc
3. nm -gC c.o
    
This produces:
00000000 W atoi
         U __strtol_internal
00000000 T f()

I would expect an "U atoi" instead of the first two.

This occurs on Red Hat Enterprise Linux beta Taroon 2.  gcc-c++-3.2.3-19

Witout optimization, one gets the expected result.

One problem this behaviour cases occurs is the object file is placed in an
archive library.  If an application which links with this library uses, in this
case, atoi(), then this object file will be included in the end result.  Even if
there are no "real" references to it.  Which of course means any constructors of
global objects, or other side effects of its inclusion, will also happen.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]