[clang] [compiler-rt] [UBSan] Add -fsanitize=uninitialized-read check (ISO C 6.3.2.1p2) (PR #207529)

via llvm-commits llvm-commits at lists.llvm.org
Sun Jul 5 09:07:10 PDT 2026


devsw-prayas wrote:

@zwuis Fair, and you're right, not a nitpick. The whole-function check is
weaker than what -Wuninitialized already does with its CFG dataflow, so as-is
this doesn't add much over that.

Plan: swap it for a per-candidate-scalar shadow i1. Resets to false at the
declaration (so loops work correctly), gets set to true at every write/init,
checked at each flagged read. That makes it path sensitive, e.g.
`if (cond) x = 1; use(x);` would trap exactly when cond was false at runtime.

Cost is one alloca + one store per write + one load/branch per read, for
candidate scalars only. Given -fsanitize=undefined is supposed to stay cheap,
wanted to check before implementing: fine as part of the Undefined group, or
would you rather this sit behind its own flag?

Holding off on the implementation until we land on this.

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


More information about the llvm-commits mailing list