[Bug c++/11137] [3.3 Regression] Linux shared library constructors not called unless there's one global object

pinskia at physics dot uc dot edu gcc-bugzilla@gcc.gnu.org
Sun Jun 29 15:58:00 GMT 2003


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

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



------- Additional Comments From pinskia at physics dot uc dot edu  2003-06-29 15:58 -------
I forgot to put the testcase I used:
pr11137.cc:
extern "C" int printf(const char*,...);
void f() __attribute__((constructor));
void f()
{
        printf("Hi\n");
}
pr11137.1.cc:
int main() {return 0;}

gcc -shared -o pr11137.so  pr11137.cc
gcc pr11137.1.cc pr11137.so
env LD_LIBRARY_PATH=.:${LD_LIBRARY_PATH} ./a.out

It should be print "Hi" but it does not on 3.3.1 (20030616) because gcc does not create a 
function which calls f() but 3.4 does.



More information about the Gcc-bugs mailing list