From: SourceForge.net <no...@so...> - 2007-05-21 08:34:39
|
Bugs item #1708027, was opened at 2007-04-27 00:22 Message generated for change (Settings changed) made by dannysmith You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=102435&aid=1708027&group_id=2435 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: gcc Group: None >Status: Closed >Resolution: Rejected Priority: 5 Private: No Submitted By: Motl (himotl) Assigned to: Danny Smith (dannysmith) Summary: static member constructors aren't called Initial Comment: Hi, gcc 3.4.4 ld 2.17.50 When linking against c++ library, static member constructors aren't called before main(), neither for static nor for dynamic linking. The strange thing here is that it works fine when the library is built on Cygwin with the same compiler/linker. I 'm not an expert, but it seems to be mingw runtime issue. ---------------------------------------------------------------------- Comment By: Danny Smith (dannysmith) Date: 2007-04-28 12:38 Message: Logged In: YES user_id=11494 Originator: NO The reason that the ctor is not invoked by the app is that the object containing the ctor is not linked in. Look at output of 'nm main.o'. To force it to be linked in you could add a non-inline ctor to class Outer, eg class Outer { public: Outer(); private: static Inner inn; }; and define Outer::Outer(){}; in the library module s.cpp ---------------------------------------------------------------------- Comment By: Motl (himotl) Date: 2007-04-27 21:35 Message: Logged In: YES user_id=1779125 Originator: YES File Added: static.tgz ---------------------------------------------------------------------- Comment By: Danny Smith (dannysmith) Date: 2007-04-27 06:24 Message: Logged In: YES user_id=11494 Originator: NO Testcase please. Danny ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=102435&aid=1708027&group_id=2435 |