https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71660

--- Comment #11 from Peter Cordes <peter at cordes dot ca> ---
(In reply to Thiago Macieira from comment #10)
> Actually, PR 65146 points out that the problem is not efficiency but
> correctness. An under-aligned type could cross a cacheline boundary and thus
> fail to be atomic in the first place.

As I pointed out there, you technically could solve the correctness problem by
checking alignment and falling back to locking for objects where a plain 8B
load or 8B store wouldn't be atomic.  That's what I meant by "efficiently
lock-free".  And we're talking about *huge* inefficiencies here compared to
always being able to inline and SSE load/store.

That would let you keep struct layouts the same, but it would still be an ABI
change, since everything has to agree about which objects are lock-free and
which aren't.  Now that I think about it, all of my suggested fixes on PR 65146
are effectively ABI changes.

> Those structures were disasters waiting to happen.

Yes, exactly.

Basically any existing binaries compiled with a gcc that allows under-aligned
atomic objects are unsafe, so keeping compatibility with them is not important.

Reply via email to