[Bug c/40693] atomic built-ins malfunction with 64-bit and optimization

m dot rosellini at f5 dot com gcc-bugzilla@gcc.gnu.org
Thu Jul 9 00:10:00 GMT 2009



------- Comment #1 from m dot rosellini at f5 dot com  2009-07-09 00:10 -------
I forgot to add: You need to compile this with -O2 and -march=pentium.

The way that negative constants are handled in the code emitted for
__sync_blah_and_blah is incorrect when the pointer type is 64-bits and the
platform is 32-bit x86.  That's the real issue.  Calling
__sync_blah_and_blah(ptr, -1) is sufficient (where ptr is a pointer to a 64-bit
signed type).  Then you do not need to turn on optimization.

This doesn't really have anything to do with optimization... it's just that
there is a strange interplay with optimization whereby the function has the bad
behavior exhibited with constants even when it doesn't look like one is passing
a constant (such as when calling this through an inline function).


-- 

m dot rosellini at f5 dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |m dot rosellini at f5 dot
                   |                            |com


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



More information about the Gcc-bugs mailing list