Optimization of conditional access to globals: thread-unsafe?
Robert Kiesling
kiesling@earthlink.net
Mon Oct 29 10:07:00 GMT 2007
> From: "Dave Korn" <dave.korn@artimi.com>
> Date: Mon, 29 Oct 2007 01:16:07 -0000
>
> > Thing is, if you disable all optimisations that are potentially
> > unsafe in the presence of threads, won't you just get the same
> > effect as if you had used volatile anyway, only on every single
> > variable in the program instead of just the ones the programmer has
> > designated as sensitive?
>
> This is not really what is being suggested at all.
>
> The compiler simply cannot speculatively load or store to variables
> with global visibility.
Any optimization is good, and GCC's is great, though debugging it is hell,
and I do not see the problem with an option to turn off somebody's pet
feature when I need to.
It really is up to the programmer to decide how the program behaves, not a
standards committee.
Just my 0.02, again.
More information about the Gcc-help
mailing list