Issue 56062
Summary wrong code on valid code at O2+ (clang 14)
Labels new issue
Assignees
Reporter ecatmur
    ```c++
int main() {
    struct D { struct P { int x, y; } a[2] = {}; } d;
    if (d.a[0].y != 0)
        throw &d.a[0].y;
}
```
```sh
$ clang++ --version
clang version 14.0.0
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/clang-14.0.0/bin
$ clang++ -O2 a.cpp && ./a.out
terminate called after throwing an instance of 'int*'
Aborted
```
clang 13 is not affected. According to godbolt it doesn't miscompile in clang trunk 15.0.0, but the bug is pretty fragile so I'm not sure that it's genuinely fixed. I'll try to bisect to find where it was introduced/removed.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to