This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Optimization of conditional access to globals: thread-unsafe?
- From: Robert Kiesling <kiesling at earthlink dot net>
- To: gcc-help at gcc dot gnu dot org
- Date: Sun, 28 Oct 2007 23:27:47 -0400 (EDT)
- Subject: Re: Optimization of conditional access to globals: thread-unsafe?
> 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.