This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/11152] New: SIGSEGV on a simple static method when using -O3


PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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

           Summary: SIGSEGV on a simple static method when using -O3
           Product: gcc
           Version: 3.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: fspublic@onetel.com
                CC: gcc-bugs@gcc.gnu.org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu

SIGSEGV on static method that just returns the content of a static variable when
using -O3. Wrong code generated? If I put a printf("OK") in the method, no
problem. If I compare with O2, different registers are used. If I modify
assembler output from O3 and change register eax to ecx except for return, no
more SIGSEGV.



g++ -frepo  -o com/westerngeco/omega/db/UserNameSingleton.o   -O3 -D__PERL
-DOMNIWORKS -DOMNI62 -DUNIX -D
X86 -DLINUX -DUSE_PKG -DHAVE_CXX -DJAVAORB -DNOMINMAX -DOMEGA -DOMEGA2
-DOMEGA_VERSION=1.8.3 -DMPI -D_FIL
E_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -DOMNIORB -DGCC -DOM_WG1  -DOM_WG1
-D_Lang_C_  -D_GNU_SOURCE -D_MT -
fPIC -DNDEBUG -I/omega2/baselines/OM2.0.1-b-003/linux_2.4_opt
-I/omega2/baselines/OM2.0.1-b-003/src -I/om
ega2/baselines/src_extern-d-001
-I/data/Domen001/omega2/omega2_env/packages/omni/client/6.2C562/linux_2.2
_x86 `gprintenv INC_PATH` `search_path
com/westerngeco/omega/db/UserNameSingleton.cc` 


C++ code:

UserNameSingleton* UserNameSingleton::instance = new UserNameSingleton();

UserNameSingleton&
UserNameSingleton::getInstance() // static method
{
    return *instance;
}

-O3: causes SIGSEGV
.globl _ZN3com11westerngeco5omega2db17UserNameSingleton11getInstanceEv
        .type   _ZN3com11westerngeco5omega2db17UserNameSingleton11getInstanceEv,
@function
_ZN3com11westerngeco5omega2db17UserNameSingleton11getInstanceEv:
.LFB848:
        call    .LPR0
        addl    $_GLOBAL_OFFSET_TABLE_, %eax
        pushl   %ebp
.LCFI10:
        movl   
_ZN3com11westerngeco5omega2db17UserNameSingleton8instanceE@GOT(%eax), %edx
        movl    %esp, %ebp
.LCFI11:
        popl    %ebp
        movl    (%edx), %eax
        ret
.LFE848:
.LPR0:
        movl    (%esp), %eax
        ret


Working:
-O2
.globl _ZN3com11westerngeco5omega2db17UserNameSingleton11getInstanceEv
        .type   _ZN3com11westerngeco5omega2db17UserNameSingleton11getInstanceEv,
@function
_ZN3com11westerngeco5omega2db17UserNameSingleton11getInstanceEv:
.LFB787:
        call    .LPR2
        addl    $_GLOBAL_OFFSET_TABLE_, %ecx
        pushl   %ebp
.LCFI0:
        movl   
_ZN3com11westerngeco5omega2db17UserNameSingleton8instanceE@GOT(%ecx), %eax
        movl    %esp, %ebp
.LCFI1:
        popl    %ebp
        movl    (%eax), %eax
        ret
.LFE787:
.LPR2:
        movl    (%esp), %ecx
        ret


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]