GCC warnings for unused global variables
Paul Jarc
prj@po.cwru.edu
Fri May 2 15:22:00 GMT 2003
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
More information about the Gcc
mailing list