Skip to content

[clang] Miscompilation at -Os #119646

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions