Skip to content

[clang] Miscompile at -O2/3 #132724

@cardigan1008

Description

@cardigan1008

This code prints 83619472 at -O0/1 and 83619480 at -O2/3:

int printf(const char *, ...);
int a, b;
int main() {
  int c = 7;
  float d = 0;
  while (c) {
    d++;
    c /= 2;
    a = 384 + 1;
  }
  float e = a + 2;
  b = d + 1.442695f * (e * e * e);
  printf("%d\n", b);
}

Compiler Explorer: https://godbolt.org/z/f5bf9os1P

Bisected to 17d9560, which was committed by @zahiraam

Metadata

Metadata

Assignees

Labels

floating-pointFloating-point mathmiscompilationquestionA question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions