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

--- Comment #2 from Thomas Koenig <tkoenig at gcc dot gnu.org> ---
Looks like this has been fixed in the meantime:

tkoenig@gcc188:~> gcc -O3 small.c 
small.c: In function 'main':
small.c:6:21: warning: iteration 2147483646 invokes undefined behavior
[-Waggressive-loop-optimizations]
    6 |     for (b = 1; b; b++)
      |                    ~^~
small.c:6:17: note: within this loop
    6 |     for (b = 1; b; b++)
      |                 ^
tkoenig@gcc188:~> gcc --version
gcc (GCC) 14.0.0 20231101 (experimental) [master r13-4915-g9b111debbfb]
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

tkoenig@gcc188:~> cat small.c 
unsigned char a[5];
int b, d;
char c;
int main() {
  if (d) {
    for (b = 1; b; b++)
      c &= d = 1;
    for (; d < 5; d++)
      c &= a[d];
  }
  return 0;
}

Still interesting which revision fixed it.

Reply via email to