Am Sonntag, den 07.11.2021, 10:08 +0100 schrieb Martin Uecker:
> It would be great if somebody could take a look at
> PR96159. 
> 
> It seems we do not do atomic accesses correctly
> when the alignment is insufficient for a lockfree
> access, but I think we should fall back to a
> library call in this case (as clang does).
> 
> This is very unfortunate as it is an important
> functionality to be able to do atomic accesses 
> on non-atomic types and it seems there is no way
> to achieve this.
> 
> Also documentation and various descriptions of
> the atomic functions imply that this is expected
> to work.
> 
> But maybe I am missing something and the generated
> code is indeed safe.
> 
> Martin
> 

Could this bug be confirmed please? 

This is a silent and dangerous incorrect code generation issue.  

If these functions are not meant to be used to exising
data,  then at least the documentation needs to be changed
and include a big warning that this only happens to work
corectly if the data has  sufficient alignment for the
specific architecture (which of course makes it impossible
to use this in a portable way).

I would then propose to add atomic_load_safe,
so that it is possible to use such functionality safely
on existing data structures which is an important use
case.

Martin




Reply via email to