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:
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
cedarpp.h