Skip to content

Wrong code at -O1 and above on x86_64-linux_gnu(recent regression) #76162

Closed
@shao-hua-li

Description

@shao-hua-li

Clang at -O1 and above produces the wrong code.

Bisected to 8773c9b, which was committed by @mgudim

Compiler explorer: https://godbolt.org/z/aTKK3Prqs

% cat reduced.c
int printf(const char *, ...);
int a, b = 7, c;
int *d = &c;
int e() { return 1 & b; }
int main() {
  char f = -1;
  *d = a + f == e() + f + f;
  printf("%d\n", c);
}
%
% clang -O0 reduced.c && ./a.out
1
% clang -O1 reduced.c && ./a.out
0
%

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions