[clang] [C++26][clang] Implement P2795R5 'Erroneous behaviour for uninitialized reads' (PR #177614)
Erich Keane via cfe-commits
cfe-commits at lists.llvm.org
Fri Jan 23 09:12:29 PST 2026
================
@@ -976,8 +976,34 @@ static void DiagUninitUse(Sema &S, const VarDecl *VD, const UninitUse &Use,
bool IsCapturedByBlock) {
bool Diagnosed = false;
+ // [basic.indet]/p1.1:
+ // - If the object has dynamic storage duration, or is the object associated
+ // with a variable or function parameter whose first declaration is marked
+ // with the [[indeterminate]] attribute ([dcl.attr.indet]), the bytes have
+ // indeterminate values;
+ //
+ // - otherwise, the bytes have erroneous values, where each value is
+ // determined
+ // by the implementation independently of the state of the program.
+ //
+ // If variable has automatic storage duration and does
+ // not have [[indeterminate]], reading it is erroneous behavior (not
+ // undefined). However, we still warn about it.
+ bool IsErroneousBehavior = S.getLangOpts().CPlusPlus26 &&
----------------
erichkeane wrote:
```suggestion
bool IsErroneousBehavior =
```
https://github.com/llvm/llvm-project/pull/177614
More information about the cfe-commits
mailing list