O2 Agressive Optimisation by GCC
Allan Sandfeld Jensen
linux@carewolf.com
Mon Jul 23 05:48:00 GMT 2018
On Sonntag, 22. Juli 2018 17:01:29 CEST Umesh Kalappa wrote:
> Allan ,
>
> >>he might as well go traditional
>
> you mean using the locks ?
>
No I am meant relying on undefined behavior. In your case I would recommend
using modern atomics, which is defined behavior, and modern and fast. I was
just reminded of all the nasty and theoretically wrong ways we used to do
stuff like that 20 years ago to implement fallback locks. For instance using -
O0, asm-declarations, relying on non-inlined functions calls as memory-
barriers, etc. All stuff that "worked", but relied on various degrees of
undefined behavior.
Still if you are curious, it might be fun playing with stuff like that, and
try to figure for yourself why it works, just remember it is undefined
behavior and therefore not recommended.
'Allan
More information about the Gcc
mailing list