Issue 165847
Summary The issue when using clang 21 with the `-O2` compilation flag
Labels clang
Assignees
Reporter solomonwzs
    Hello, I have a piece of code that, when compiled with clang 21 and the `-O2` flag, produces an executable that crashes with a coredump at runtime.

The problematic compilation command is:
```
clang++ -O2 main.cpp
```

However, if I omit the `-O2` flag, or use an older version of Clang or GCC to compile, the resulting executable runs without any issues. For example:
```
# Without `-O2`
clang++ main.cpp

# Using GCC
g++ main.cpp
g++ -O2 main.cpp

# Using an older version of Clang
/usr/lib/llvm20/bin/clang++ -O2 main.cpp
```

[main.cpp](https://github.com/user-attachments/files/23257372/main.cpp)
[cedarpp.h](https://github.com/DevO2012/cedar/blob/master/cedarpp.h)
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to