https://sourceware.org/bugzilla/show_bug.cgi?id=22762
Bug ID: 22762 Summary: missing static variable constructor calls Product: binutils Version: 2.30 Status: UNCONFIRMED Severity: normal Priority: P2 Component: ld Assignee: unassigned at sourceware dot org Reporter: ssbssa at yahoo dot de Target Milestone: --- When trying a program as simple as that: > #include <stdio.h> > > class Printer > { > public: > Printer() > { > printf("Printer()\n"); > } > }; > > static Printer printer; > > int main() > { > return 0; > } No output is visible, because the static constructors are no longer called. My investigation got me to this commit: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commitdiff;h=ca6f2be7f6bc638fd4fad48def1fae4ae4d7906e This added PROVIDE() to both __CTOR_LIST__ and __DTOR_LIST__, and the docu (https://sourceware.org/binutils/docs/ld/PROVIDE.html) states: > The PROVIDE keyword may be used to define a symbol, such as ‘etext’, only if > it is referenced but not defined. But since it's already defined, it's no longer added by ld: > $ g++ -ostatic-var.exe static-var.cpp -Wl,-T,static-var-ld.txt > -Wl,-y,___CTOR_LIST__ > c:/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/7.2.0/../../../../i686-w64-mingw32/lib/../lib/libmingw32.a(lib32_libmingw32_a-gccmain.o): > reference to ___CTOR_LIST__ > c:/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/7.2.0/libgcc.a(_ctors.o): > definition of ___CTOR_LIST__ I didn't find _ctors.c, but I think the definition is from here: https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=libgcc/libgcc2.c;h=f418f3a354de4b74d88ba9697b0ac5b8aa71ae03;hb=HEAD#l2358 -- You are receiving this mail because: You are on the CC list for the bug. _______________________________________________ bug-binutils mailing list bug-binutils@gnu.org https://lists.gnu.org/mailman/listinfo/bug-binutils