http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46706
Summary: global constructors does not work properly since changes from bug 29141 Product: gcc Version: 4.4.0 Status: UNCONFIRMED Severity: critical Priority: P3 Component: c++ AssignedTo: unassig...@gcc.gnu.org ReportedBy: mschu...@ivs.cs.ovgu.de CC: mschu...@ivs.cs.ovgu.de Target: avr In my opinion the bug 29141 is still pending and not fixed. I reported it there but until now no reaction and I am not able to reopen the bug thus I open a new one. The proposed fix of bug 29141 rises another issue. Since this change, global constructors does not work properly anymore. The fix uses register r20 within the __do_global_ctors loop but this register could be clobbered by a constructor that is called, leading to destructing the exit condition of the __do_global_ctors loop. In new version of gcc (see bug 45263 but still not confirmed) this is weakly fixed by pushing and poping r20 around the constructor call. I would suggest using a register between r2-r17 instead of r20. According to the compiler abi this should be a register that the called routine has to save if it needs to use it. In my eyes, this is a critical or maybe a blocker bug, because global objects can not be used as long as r20 is used unprotected without pushing/poping, or by using another register instead that is not faced by this problem. Affected gcc versions 4.4.0 - 4.5.1