This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/40693] atomic built-ins malfunction with 64-bit and optimization
- From: "m dot rosellini at f5 dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 9 Jul 2009 00:10:03 -0000
- Subject: [Bug c/40693] atomic built-ins malfunction with 64-bit and optimization
- References: <bug-40693-17927@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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