Skip to content

clang hangs when compile at -O3 on x86_64 #70936

@junweizeng

Description

@junweizeng

Compiler explorer: https://godbolt.org/z/PdsEMbY6b

When compile the following program using clang under -O3, it hangs.

int a;
int b;
short c() {
  volatile unsigned char d = 2;
  int e = 1;
  a = 0;
  for (; a < 3; a++) {
    b = 0;
    for (; b < 10; b++)
      do {
        e -= 3;
        d;
      } while (e > 2);
  }
  for (int f = 0;;)
    ;
}
int main() {}

I found this bug exists on clang-16.0.0, clang-17.0.1 and the latest trunk.

Metadata

Metadata

Assignees

No one assigned

    Labels

    hangCompiler hang (infinite loop)llvm:SCEVScalar Evolution

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions