This is the mail archive of the
mailing list for the GCC project.
Re: Optimization of conditional access to globals: thread-unsafe?
> Frankly, you realise the consequences of volatile access, you have
> this comment:
> /* Avoid reading __gthread_active twice on the main code path. */
> int __gthread_active_latest_value = __gthread_active;
> Now, do you really believe that every multithreaded program should use
> volatile, and then should copy shared data to temporal storage, just
> because volatile is such a hammer?
No, I just wanted to point out that "volatile" has a well-defined semantics
and can be properly used for shared accesses. In other words, it's not all
or nothing like your earlier message[*] seemed to imply.