[clang] [RFC][clang][BPF] Make trivial uninit var value to be 0 (PR #125601)

via cfe-commits cfe-commits at lists.llvm.org
Sat Feb 8 17:00:05 PST 2025


eddyz87 wrote:

I looked at the example shared by Yonghong, the change clang does because of the uninitialized variable access is indeed quite dramatic. It computes a switch over `undef` and throws away all branches including "default". Basically throwing away most of the program.

Nevertheless, the issue is not really solved by using zero initialization, as that is not what programmer intended and might be equally as hard to debug. And this is not limited to BPF backend. If we really consider this issue to be a priority for BPF backend, I think we should invest time in better semantic warnings, or otherwise leave things as is.

https://github.com/llvm/llvm-project/pull/125601


More information about the cfe-commits mailing list