[Bug middle-end/51766] [4.7 regression] sync_fetch_and_xxx atomicity

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Jan 10 18:20:00 GMT 2012


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

--- Comment #9 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-01-10 18:20:00 UTC ---
(In reply to comment #8)
> For the way that programmers use __sync_* builtins, release or acquire-release
> semantics are sufficient.

Are you claiming you know how all programmers have used those builtins?

>  As we see in libstdc++, release semantics are overly
> strict when incrementing the reference, as opposed to destroying an object.
> 
> Again, there is no cost to Intel specifying sequential consistency as opposed
> to a slightly weaker memory model.  Intel chose a memory model that matched and
> benefited their architecture.  IBM should have the freedom to choose memory
> models that benefit its architectures.

How or why Intel chose those semantics is not really relevant, the fact is that
with the exception of lock_test_and_set and lock_release the __sync builtins
are documented to be full barriers, and always have been documented as full
barriers, both in GCC's and Intel's docs. If someone uses them in their code
relying on the fact they'll get a full barrier, then someone else runs that
code on POWER and there's a bug because it isn't a full barrier, who is to
blame for the bug?

That said, I don't have any personal interest in what they do on POWER, as long
as I'm not asked to deal with any libstdc++ bugs resulting from the builtins
not behaving as documented.



More information about the Gcc-bugs mailing list