http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55981
--- Comment #1 from Evgeniy Stepanov <eugeni.stepanov at gmail dot com> 2013-01-14 22:45:30 UTC --- Disassembly of the loop in ff() function: 4007c0: movl $0x2,0x2008de(%rip) # 6010a8 <y> 4007ca: movl $0x1,0x2008d8(%rip) # 6010ac <y+0x4> 4007d4: sub $0x1,%eax 4007d7: mfence 4007da: movl $0x4,0x2008c4(%rip) # 6010a8 <y> 4007e4: movl $0x3,0x2008be(%rip) # 6010ac <y+0x4> 4007ee: mfence 4007f1: jne 4007c0 <_Z2ffv+0xb0> Does not look atomic. Has all the proper fences, though.