[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


================
@@ -2012,7 +2026,7 @@ void CodeGenFunction::EmitAutoVarInit(const AutoVarEmission &emission) {
     if (emission.IsEscapingByRef && !locIsByrefHeader)
       Loc = emitBlockByrefAddress(Loc, &D, /*follow=*/false);
 
-    return emitZeroOrPatternForAutoVarInit(type, D, Loc);
+    return emitZeroOrPatternForAutoVarInit(type, D, Loc, trivialAutoVarInit);
----------------
rnk wrote:

Does the paper require compilers to initialize fields of records in addition to trivial variables? Otherwise, you can still trigger UB if the constructor leaves fields uninitialized, as in cases like this, where we return `undef`:
https://godbolt.org/z/zaWcWhdPP

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


More information about the cfe-commits mailing list