This is the mail archive of the
mailing list for the GCC project.
Re: Optimization of conditional access to globals: thread-unsafe?
- From: Robert Dewar <dewar at adacore dot com>
- To: Andrew Haley <aph-gcc at littlepinkcloud dot COM>
- Cc: Bart Van Assche <bart dot vanassche at gmail dot com>, gcc at gcc dot gnu dot org, Andrew Pinski <pinskia at gmail dot com>, Tomash Brechko <tomash dot brechko at gmail dot com>
- Date: Fri, 26 Oct 2007 11:15:01 -0400
- Subject: Re: Optimization of conditional access to globals: thread-unsafe?
- References: <email@example.com> <firstname.lastname@example.org> <email@example.com>
Andrew Haley wrote:
Hmmm. This is an interesting idea, but it sounds to me as though it's
somewhat at variance with what is proposed by the C++ threads working
group. In any case, gcc will certainly implement whatever the
standards committees come up with, but that is probably two years
One problem at the language standards level is that you can't easily
talk about loads and stores, since you are defining an as-if semantic
model, and if you make a statement about loads and stores, any other
sequence which behaves as if that sequence were obeyed is allowed. In
the absence of a notion of threads at the semantic level it's difficult
to say what you mean in a formal way. In the Ada standard, we get
around this problem by having sections called "implementation advice",
which in practice are treated as requirements, but we can use language
that is not formally sound, even though everyone knows what we mean.
Of course in Ada there is a clear notion of threads semantic, and
a clear definition of what the meaning of code is in the presence
of threads, so the specific situation discussed here is easy to
deal with (though Ada takes the view that unsychronized shared access to
non-atomic or non-volatile data from separate threads has undefined