Skip to content

[clang] Miscompilation at -O2/3 #131465

@cardigan1008

Description

@cardigan1008

This code prints 80 at -O2/3 and 0 at -O0/1:

int printf(const char *, ...);
int a, b;
void c(char d) { a = d; }
int main() {
  int e = 82, f = 20;
  for (; 85 + 20 + e - 187 + f; f = 65535 + 20 + e - 65637)
    if (b)
      e++;
  c(e >> 24);
  printf("%X\n", a);
}

Compiler Explorer: https://godbolt.org/z/6WP1aT6ba

Bisected to 04cd069, which was committed by @preames

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions