Skip to content

[clang] Miscompilation at -Os #119646

Closed
Closed
@cardigan1008

Description

@cardigan1008

This code prints 1 at -Os and 0 at -O0/1/2/3:

int printf(const char *, ...);
long a, b = 208;
short c;
long(d)(long e) { return (a && e && 2036854775807 / e) * a; }
void f(long *e) {
  if (d(c | (*e = b || 0)))
    for (;;)
      ;
}
int main() {
  long *g = &b;
  *g = 0;
  f(&b);
  printf("%d\n", (int)b);
}

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

Bisected to ebe741f which was committed by @haopliu

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions