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

            Bug ID: 111833
           Summary: GCC: 14: hangs on a simple for loop
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: 141242068 at smail dot nju.edu.cn
  Target Milestone: ---

Compiler Explorer: [https://gcc.godbolt.org/](https://gcc.godbolt.org/)

Here is the code snippet that is causing the issue:

```c
unsigned char a[1];
unsigned char b;

void f(void) {
  unsigned char r = 0;
  int n;
  for (n = 8; n / sizeof(a); ++n) {
    b += b;
    r += b;
  }
}
```

This bug shares the same options as bug #111820, but the root cause seems to be
different:

While bug #111820 appears to get stuck in a loop when the initial value is zero
(as suggested by the comment `Maybe the loop should terminate when begin is
zero.`), this particular bug causes a hang starting from the initial value of
8. This suggests that the issue may not be tied to the initial loop value, but
some other aspect of the loop's iteration or the operations within it.

Reply via email to