[clang] [C++26][clang] Implement P2795R5 'Erroneous behaviour for uninitialized reads' (PR #177614)
Reid Kleckner via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 7 06:49:23 PDT 2026
https://github.com/rnk commented:
I saw a post about this paper on [reddit](https://www.reddit.com/r/cpp/comments/1uo5y63/c26_ends_a_40year_footgun/), and thought, I don't think that's been implemented in Clang/LLVM, and went to check the status. The [feature status tracker page](https://clang.llvm.org/cxx_status.html) shows this is still open, and this PR is the only PR mentioning this paper, so it's the most current attempt.
I think I really wanted to loop in LLVM optimizer people to ask the question, if this is the future, *why does mem2reg still produce undef for uninitialized reads*?
cc @jyknight @alinas @nikic
As in the [case I linked](https://godbolt.org/z/zaWcWhdPP), frontends are going to forget to initialize things going forward, and if we want to implement P2795 correctly, I don't think the optimizer can produce `undef` when it deletes an uninitialized read.
I think LLVM still needs an undef concept to enable other kinds of speculation, but it seems to me that SROA/mem2reg could simply materialize zero at this point, and we'd all live better lives for it.
This conversation is probably better continued on Discourse or in a github issue.
https://github.com/llvm/llvm-project/pull/177614
More information about the cfe-commits
mailing list