Skip to content

wrong code at -O1 on x86_64-linux-gnu #87534

Closed
@zhendongsu

Description

@zhendongsu

It appears to be a regression from 14.0.0, and affects 15.* and later.

Compiler Explorer: https://godbolt.org/z/57cnEr81r

[546] % clangtk -v
clang version 19.0.0git (https://github.com/llvm/llvm-project.git 07a566793b2f94d0de6b95b7e6d1146b0d7ffe49)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /local/suz-local/software/local/clang-trunk/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11
Candidate multilib: .;@m64
Selected multilib: .;@m64
[547] % 
[547] % clangtk -O1 small.c
[548] % ./a.out
Aborted
[549] % cat small.c
struct a {
  int b;
  int c;
  int d;
  int e;
  int f;
} g, h = {1,0,0,0,0}, *i;
void j(struct a k) {
  struct a *l = &g;
  if (k.b)
    l = i = &k;
  if (l != &k)
    __builtin_abort();
}
int main() {
  j(h);
  return 0;
}

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions