This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Optimization of conditional access to globals: thread-unsafe?
Tomash Brechko <tomash.brechko@gmail.com> writes:
> - the compiler should not introduce speculative stores to the shared
> objects. This is what my original question was about. I haven't
> read all the papers yet, so one thing is still unclear to me: it
> seems like atomic variables will be annotated as such
> (atomic<int>). But I found no proposal for annotation of
> non-atomic objects that are protected by the ordinary locks (like
> mutexes). Will the compiler be forbiden to do all speculative
> stores, or how will it recognize shared objects as such?
In practice, gcc will provide a variable attribute to mark the
variable as atomic.
The language standard does not forbid speculative stores to non-atomic
objects.
Ian