Skip to content

[clang] Miscompilation at -O2/3 #121745

Closed
Closed
@cardigan1008

Description

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

int printf(const char *, ...);
static char a;
static char *b = &a;
static int c;
short d;
void e() {
  short f[8];
  char **g[] = {&b, &b};
  c = 0;
  for (; c < 8; c = 81 + 462704684 + *b - 462704765 + c + 1)
    f[c] = 0;
  d = f[5];
}
int main() {
  e();
  printf("%d\n", c);
}

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

Bisected to df4a615, which was committed by @fhahn

Activity

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

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions