Am Montag, den 08.11.2021, 11:59 +0000 schrieb Jonathan Wakely:
> On Sun, 7 Nov 2021, 09:08 Martin Uecker wrote:
> 
> > 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.
> > 
> 
> C++ solves this with std::atomic_ref<T> which has a precondition that the
> non-atomic object being operated on is suitably aligned.

>  Working with
> arbitrary objects is not supported, the user must ensure the alignment is
> correct.
> 
> That seems like a reasonable restriction to me.

It is in so far not reasonable as you can not use atomic
operations safely on existing data structures, but
this is an important requirement in some applications.

And it would trivial to support just by calling into
libatomic as clang does.

Martin




Reply via email to