[Bug c++/46682] New: __sync_bool_compare_and_swap generates wrong code
us15 at os dot inf.tu-dresden.de
gcc-bugzilla@gcc.gnu.org
Sat Nov 27 07:01:00 GMT 2010
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46682
Summary: __sync_bool_compare_and_swap generates wrong code
Product: gcc
Version: 4.5.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: us15@os.inf.tu-dresden.de
Created attachment 22544
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=22544
Testcase
Compile testcase with:
gcc-4.5.1 -MP -MMD -pipe -m32 -Os -march=i686 -mpreferred-stack-boundary=2
-mregparm=3 -fdata-sections -ffunction-sections -fomit-frame-pointer
-freg-struct-return -freorder-blocks -funit-at-a-time -fno-exceptions -fno-rtti
-fno-stack-protector -fvisibility-inlines-hidden -Wall -Wextra
-Waggregate-return -Wcast-align -Wcast-qual -Wconversion
-Wdisabled-optimization -Wformat=2 -Wmissing-format-attribute
-Wmissing-noreturn -Wpacked -Wpointer-arith -Wredundant-decls -Wshadow
-Wwrite-strings -Wabi -Wctor-dtor-privacy -Wno-non-virtual-dtor
-Wold-style-cast -Woverloaded-virtual -Wsign-promo -Wframe-larger-than=64
-Wlogical-op -Wstrict-null-sentinel -Wstrict-overflow=5 -Wvolatile-register-var
-c testcase.cc -o testcase.o
This results in:
00000000 <Ec::generate_wrong_code()>:
0: 53 push %ebx
1: b8 01 00 00 00 mov $0x1,%eax
6: e8 fc ff ff ff call 7 <Ec::generate_wrong_code()+0x7>
b: 31 d2 xor %edx,%edx
d: 31 c9 xor %ecx,%ecx
f: 6a 00 push $0x0
11: 6a 00 push $0x0
13: 6a 00 push $0x0
15: 89 c3 mov %eax,%ebx
17: e8 fc ff ff ff call 18 <Ec::generate_wrong_code()+0x18>
1c: 8b 15 00 00 00 00 mov 0x0,%edx
22: 31 c0 xor %eax,%eax
24: f0 0f b1 1a lock cmpxchg %ebx,(%edx)
28: 83 c4 0c add $0xc,%esp
2b: 74 07 je 34 <Ec::generate_wrong_code()+0x34>
2d: b8 01 00 00 00 mov $0x1,%eax
32: eb 02 jmp 36 <Ec::generate_wrong_code()+0x36>
34: 31 c0 xor %eax,%eax
36: e8 fc ff ff ff call 37 <Ec::generate_wrong_code()+0x37>
The "add" at offset 28 is messing up the flags for the "je" at offset 2b.
More information about the Gcc-bugs
mailing list