Skip to content

[clang] Miscompilation at -O3 #119173

Closed
@cardigan1008

Description

@cardigan1008

This code prints 15 at -O3, but prints 5 at -O0/1/2:

int printf(const char *, ...);
static int a[] = {4294967295, 5};
int b, c;
int main() {
  a[1] = b = 5;
  unsigned d = -13;
  for (; d >= 8; d = a[0] + d + 6) {
    int *e = &b;
    *e = a[0] - -1 + b;
  }
  a[c];
  printf("%d\n", b);
}

Compiler Explorer: https://godbolt.org/z/4xdPqcjPb

Bisected to 6d6eea9, which was committed by @fhahn

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    Status

    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions