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

            Bug ID: 98159
           Summary: Compiler generates infinite loop
           Product: gcc
           Version: 10.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: olme8 at mail dot ru
  Target Milestone: ---

This code creates an infinite loop when compiled with -O2/-O3.

int main() {
  int a=1;
  for(;a+=a;);
  return a;
}

The compiler doesn't think that integers have a finite number of bits.

But works with:

  for(;a<<=1;);

Which does the same.

Checked GCC versions 7.5.0 and 10.2.0. Machine is x86/x86_64.

https://godbolt.org/z/4Tb9ds

Reply via email to