This is the mail archive of the gcc@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]

[Fwd: GCC 4.0 bug]


I'm forwarding this message from a coworker.
He ran into this regression bug with GCC 4.0.1 (it works correctly in 3.4.1).
The conditional operator expression isn't handling static consts correctly resulting in linker errors since it is trying to resolve to statics that were never defined.


struct Foo
{
   static const int    a   = 1;
   static const int    b   = 2;
};


inline void foo(bool v) { std::cout << ((v) ? (Foo::a) : (Foo::b)); }


_Z3foob: .LFB1425: .file 1 "foo.cpp" .loc 1 10 0 pushl %ebp .LCFI0: movl %esp, %ebp .LCFI1: subl $24, %esp .LCFI2: movl 8(%ebp), %eax movb %al, -4(%ebp) .LBB2: .loc 1 12 0 cmpb $0, -4(%ebp) je .L2 movl _ZN3Foo1aE, %eax movl %eax, -8(%ebp) jmp .L4 .L2: movl _ZN3Foo1bE, %eax movl %eax, -8(%ebp) .L4: movl -8(%ebp), %eax movl %eax, 4(%esp) movl $_ZSt4cout, (%esp) call _ZNSolsEi .LBE2: .loc 1 13 0 leave ret .LFE1425: .size _Z3foob, .-_Z3foob


No declaration of _ZN3Foo1aE and _ZN3Foo1bE.



Changed Foo to:


struct Foo
{
   static const int    a;
   static const int    b;
};

const int   Foo::a  = 1;
const int   Foo::b  = 2;


Assembly of function the same, but in addition:


.globl _ZN3Foo1bE
       .section        .rodata
       .align 4
       .type   _ZN3Foo1bE, @object
       .size   _ZN3Foo1bE, 4
_ZN3Foo1bE:
       .long   2
.globl _ZN3Foo1aE
       .align 4
       .type   _ZN3Foo1aE, @object
       .size   _ZN3Foo1aE, 4
_ZN3Foo1aE:
       .long   1



Thanks,
Patrick Bennett



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