From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26208 invoked by alias); 25 Sep 2003 12:18:27 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 26201 invoked by uid 48); 25 Sep 2003 12:18:26 -0000 Date: Thu, 25 Sep 2003 12:29:00 -0000 From: "uddeborg at carmen dot se" To: gcc-bugs@gcc.gnu.org Message-ID: <20030925121817.12401.uddeborg@carmen.se> Reply-To: gcc-bugzilla@gcc.gnu.org Subject: [Bug c++/12401] New: G++ generates boguous weak definition of library routine X-Bugzilla-Reason: CC X-SW-Source: 2003-09/txt/msg01908.txt.bz2 List-Id: 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 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.