Bug 23472 - [hammer] __attribute__((constructor)) called twice with -funit-at-a-time
Summary: [hammer] __attribute__((constructor)) called twice with -funit-at-a-time
Status: RESOLVED WONTFIX
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.3.4
: P2 normal
Target Milestone: ---
Assignee: Michael Matz
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-08-19 01:09 UTC by Flash Sheridan
Modified: 2007-07-11 15:37 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2006-01-15 21:04:22


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Flash Sheridan 2005-08-19 01:09:33 UTC
The constructor in the code for bug 16717 (below) gets called twice when compiled by 3.3.4 with -
funit-at-a-time, but only once when called without -funit-at-a-time.  This sounds like the opposite of 
bug 16717, which was marked as a 3.4 regression, and supposedly not a problem in 3.3.4.


#include <stdio.h>

void hello (void) __attribute__ ((constructor));

void hello (void) { printf ("Hello world\n"); }

int main (void) { return 0; }


Here's the session:

 flash@thrallis scripts 18:00:33
81> /usr/bin/g++ -v -funit-at-a-time ../cpp/bugfiles/GCC_bugfiles/noerror/16717-attr-
constructor.cpp
Reading specs from /usr/lib/gcc-lib/i586-suse-linux/3.3.4/specs
Configured with: ../configure --enable-threads=posix --prefix=/usr --with-local-prefix=/usr/local --
infodir=/usr/share/info --mandir=/usr/share/man --enable-languages=c,c++,f77,objc,java,ada --
disable-checking --libdir=/usr/lib --enable-libgcj --with-gxx-include-dir=/usr/include/g++ --with-
slibdir=/lib --with-system-zlib --enable-shared --enable-__cxa_atexit i586-suse-linux
Thread model: posix
gcc version 3.3.4 (pre 3.3.5 20040809)
 /usr/lib/gcc-lib/i586-suse-linux/3.3.4/cc1plus -quiet -v -D__GNUC__=3 -D__GNUC_MINOR__=3 -
D__GNUC_PATCHLEVEL__=4 -D_GNU_SOURCE ../cpp/bugfiles/GCC_bugfiles/noerror/16717-attr-
constructor.cpp -D__GNUG__=3 -quiet -dumpbase 16717-attr-constructor.cpp -auxbase 16717-attr-
constructor -version -funit-at-a-time -o /tmp/ccKqhSCv.s
GNU C++ version 3.3.4 (pre 3.3.5 20040809) (i586-suse-linux)
        compiled by GNU C version 3.3.4 (pre 3.3.5 20040809).
GGC heuristics: --param ggc-min-expand=81 --param ggc-min-heapsize=96968
#include "..." search starts here:
#include <...> search starts here:
 /usr/include/g++
 /usr/include/g++/i586-suse-linux
 /usr/include/g++/backward
 /usr/local/include
 /usr/lib/gcc-lib/i586-suse-linux/3.3.4/include
 /usr/i586-suse-linux/include
 /usr/include
End of search list.
 /usr/lib/gcc-lib/i586-suse-linux/3.3.4/../../../../i586-suse-linux/bin/as -V -Qy -o /tmp/ccgrP3v1.o 
/tmp/ccKqhSCv.s
GNU assembler version 2.15.91.0.2 (i586-suse-linux) using BFD version 2.15.91.0.2 20040727 (SuSE 
Linux)
 /usr/lib/gcc-lib/i586-suse-linux/3.3.4/collect2 --eh-frame-hdr -m elf_i386 -dynamic-linker /lib/ld-
linux.so.2 /usr/lib/gcc-lib/i586-suse-linux/3.3.4/../../../crt1.o /usr/lib/gcc-lib/i586-suse-linux/
3.3.4/../../../crti.o /usr/lib/gcc-lib/i586-suse-linux/3.3.4/crtbegin.o -L/usr/lib/gcc-lib/i586-suse-
linux/3.3.4 -L/usr/lib/gcc-lib/i586-suse-linux/3.3.4/../../../../i586-suse-linux/lib -L/usr/lib/gcc-
lib/i586-suse-linux/3.3.4/../../.. /tmp/ccgrP3v1.o -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/
lib/gcc-lib/i586-suse-linux/3.3.4/crtend.o /usr/lib/gcc-lib/i586-suse-linux/3.3.4/../../../crtn.o
 flash@thrallis scripts 18:00:57
82> a.out
Hello world
Hello world
 flash@thrallis scripts 18:01:07
83> 
 flash@thrallis scripts 18:01:08
83> /usr/bin/g++ -fno-unit-at-a-time ../cpp/bugfiles/GCC_bugfiles/noerror/16717-attr-
constructor.cpp
 flash@thrallis scripts 18:01:37
84> a.out
Hello world
 flash@thrallis scripts 18:01:39
85>
Comment 1 Andrew Pinski 2005-08-19 01:15:32 UTC
This is a hammer branch specific bug (the branch which is used to produce SuSE's gcc).  This bug does 
not effect any FSF branch any more as PR 16717 is already fixed and unit-at-a-time was added for 
3.4.x.


Assigning it to matz per Steven B.
Comment 2 Michael Matz 2005-08-19 01:36:35 UTC
Still a problem in the current hammer branch.  CCing Honza. 
Comment 3 Paolo Carlini 2007-07-10 19:25:31 UTC
Hi Michael, I'm wondering if we still care about this PR...
Comment 4 Michael Matz 2007-07-11 15:37:32 UTC
Nope.