[Bug c++/28991] New: Static constructor emitted instead of initialized variable

us15 at os dot inf dot tu-dresden dot de gcc-bugzilla@gcc.gnu.org
Fri Sep 8 20:52:00 GMT 2006


Instead of emitting an initialized variable in .data at compile time, gcc-4.2.0
emits a variable in .bss and a static constructor to initialize the variable at
run time. This is a regression from previous gcc versions.

Example code:

class T
{
    static void (*handler)();
    static void func() {};
};

void (*T::handler)() = func;

int main()
{
    T t;
    return 0;
}

gcc version 4.2.0 20060908 (experimental) emits:
08048416 t global constructors keyed to _ZN1T7handlerE
08049664 B T::handler

4.1.1 and 3.4.6 emit:
0804962c D T::handler


-- 
           Summary: Static constructor emitted instead of initialized
                    variable
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: us15 at os dot inf dot tu-dresden dot de
 GCC build triplet: i486-slackware-linux
  GCC host triplet: i486-slackware-linux
GCC target triplet: i486-slackware-linux


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28991



More information about the Gcc-bugs mailing list