[clang] [clang][CodeGen] Zero init unspecified fields in initializers in C (PR #97121)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 16 13:40:02 PDT 2024
yabinc wrote:
According to the C23 standard, initializing a union variable with empty braces {} only guarantees the initialization of the first member and any padding after all members. This behavior deviates from common intuition and caused a bug when compiling the Linux kernel.
Based on the discussion in https://github.com/llvm/llvm-project/issues/78034, this patch aims to zero-initialize all bytes after the first member.
If this change introduces significant regressions in edge cases, a fallback strategy is to replace brace initialization with explicit assignment statements for the specific fields requiring initialization.
https://github.com/llvm/llvm-project/pull/97121
More information about the cfe-commits
mailing list