[Bug c++/22355] New: Multiple local static variables initialization: missed optimization opportunity

yuri at tsoft dot com gcc-bugzilla@gcc.gnu.org
Thu Jul 7 20:29:00 GMT 2005


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



More information about the Gcc-bugs mailing list