https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107696

--- Comment #2 from Li Shaohua <shaohua.li at inf dot ethz.ch> ---
(In reply to Martin Liška from comment #1)
> >     int i;
> >     int a[1];
> >     for (; i < 1;){ 
> 
> This depends on the uninitialized value of 'i', which is:
> 
> (gdb) p i
> $1 = 32767
> 
> if I run it with -O0 on my local machine. You can try
> -ftrivial-auto-var-init=zero.

Sorry, I over-reduced the test, for the following new test, I can still observe
the inconsistent results across optimization levels:

Compiler explorer: https://godbolt.org/z/b7x9zx5Ej
% cat a.c
int main() {
    int b[2];
    int a[1];
    int i;
    for (i=0; i < 1; i++) 
        i = i + 3;
    a[i] = 1;
}
%

Reply via email to