Bug in loop optimize (TREE stage)
Denis Chertykov
denisc@overta.ru
Wed Dec 27 18:28:00 GMT 2000
dewar@gnat.com (Robert Dewar) writes:
> << This is undefined behaviour. Since you haven't initialised variable p,
> the compiler is free to implement whatever it likes here. In particular,
> >>
>
> Presumably with warnings switched on, you would have got the appropriate
> warning which would have saved you submitting the bogus example :-)
Which warnings ?
Why I have so different result if I change 0xffffffff to 0xfffffffe ?
Or
Why I have a right result if I change `volatile unsigned char *p' to
`volatile unsigned int *p' ?
So, I can only repeat:
volatile unsigned char * volatile p;
/* ^^^^^^^^
I have added this keyword without any results in output. */
volatile unsigned char i;
/* Compiler don't know anything about P because it's a `volatile'
variable. IE any part of program can change P in any time
(interrupts, hardware, etc...).
Also, compiler must save P to it's memory location immediately
after any modification of P. */
int main(void) {
do {
i++;
} while(p++<(unsigned char *)0xffffffff);
return 0;
}
Denis.
More information about the Gcc
mailing list