Following code (f()) if compiled with -fno-exceptions should produce only one initialization boolean for all local static variables, not one per variable. This is since they always initialized together provided there are no exceptions.
If exceptions are allowed then it should be driven by the flag in constructors saying if they allow exceptions or not. Yuri --------------------------- struct C { C(); int get(); }; int f() { static C i; static C j; return (i.get() + j.get()); } -- Summary: Multiple local static variables initialization: missed optimization opportunity Product: gcc Version: 4.0.0 Status: UNCONFIRMED Severity: enhancement Priority: P2 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: yuri at tsoft dot com CC: gcc-bugs at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22355