This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: GCC warnings for unused global variables
Gabriel Dos Reis <gdr@integrable-solutions.net> wrote:
> Paul Koning <pkoning@equallogic.com> writes:
> | static volatile int foo;
> |
> | void test (void)
> | {
> | foo = 1;
> | foo = 1;
> | }
> |
> | Does your statement mean that you believe the compiler is allowed to
> | optimize this into:
> | void test (void)
> | {
> | foo = 1;
> | }
> | ?
>
> If it can determine that does nto change the behaviour of whole
> program, yes, it is permitted to do so.
Right. But the whole point of volatile is that it expresses to the
compiler "something is going on here that you don't know about".
Therefore, the compiler can never determine that this optimization
would not change the behavior of the program.
paul