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

--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Matthias Kretz (Vir) from comment #5)
> Simpler variant. I couldn't come up with a better barrier to force the last
> line to load from out than inline asm.
> 
> char in[2] = {2, 2};
> short out[2] = {};
> 
> int
> main()
> {
>   for (int i = 0; i < 2; ++i)
>     out[i] = in[i];
>   asm("":::"memory");
>   if (out[0] != 2) __builtin_abort();
> }

__atomic_signal_fence (__ATOMIC_RELAXED)  If you don't want to use inline-asm
directly (it should translate to the same thing internally though).

Reply via email to