GCC warnings for unused global variables

Mike Stump mrs@apple.com
Fri May 9 17:10:00 GMT 2003


On Friday, May 9, 2003, at 01:11 AM, Gabriel Dos Reis wrote:
> Mike Stump <mrs@apple.com> writes:
>
> | On Friday, May 2, 2003, at 07:56 AM, Gabriel Dos Reis wrote:
> | > They can be optimized out if the program cannot tell the 
> difference.
> |
> | Disagree.  I think the above is probably either confusing, or wrong.
> | We can better well what you mean if you tell us if, in:
> |
> | Given:
> |
> | extern volatile int i;
> | int main() {
> | 	i = 1;
> | 	i = 2;
> | }
> |
> | can the program tell the difference?
>
> Obviously, with no information about the definition of "i", the
> compiler does not have any information necessary to infer that the
> optimization is legit.  Where is the problem?

I can change it to:

volatile int i __attribute__((section, "iocontrol_5"));

void foo() {
	i = 1;
	i = 2;
}

or just:

volatile int i;

void foo() {
	i = 1;
	i = 2;
}

if you think that changes anything.



More information about the Gcc mailing list