[clang] [libcxx] [clang] Fix -Wuninitialized for values passed by const pointers (PR #147221)

Igor Kudrin via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 7 21:22:41 PDT 2025


================
@@ -453,7 +450,7 @@ void ClassifyRefs::VisitCallExpr(CallExpr *CE) {
       const auto *UO = dyn_cast<UnaryOperator>(Ex);
       if (UO && UO->getOpcode() == UO_AddrOf)
         Ex = UO->getSubExpr();
-      classify(Ex, Ignore);
+      classify(Ex, Use);
----------------
igorkudrin wrote:

Thank you for the explanation. These two cases, passing an uninitialized value and passing the address of such a value, are indeed different, because the address is defined. I guess that implementing your second suggestion, i.e. to use `ConstRefUse` instead of `Ignore`, requires a lot more changes; at least, the warning message needs to be updated to reflect the actual case. I'll prepare a separate PR for this.

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


More information about the cfe-commits mailing list