[libcxx-commits] [clang] [libcxx] [clang] Fix -Wuninitialized for values passed by const pointers (PR #147221)
Richard Smith via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Jul 7 13:53:18 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);
----------------
zygoloid wrote:
I believe the intent of this code is that if *the address of* a local variable is passed to a const pointer, that local variable is neither considered used nor initialized. When a local variable is passed directly to a call, no special handling should be required, because an lvalue-to-rvalue conversion will be performed, which will be classified as a use. So I think the correct fix is instead:
```suggestion
if (UO && UO->getOpcode() == UO_AddrOf) {
classify(UO->getSubExpr(), Ignore);
}
```
https://github.com/llvm/llvm-project/pull/147221
More information about the libcxx-commits
mailing list