[clang] [libcxx] [clang] Fix -Wuninitialized for values passed by const pointers (PR #147221)
Richard Smith via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 7 14:58:53 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:
> Your suggestion does not cover the case:
>
> ```
> void foo(const int *);
> void test() {
> int v;
> foo(&v);
> }
> ```
Correct. We intentionally don't warn on that -- a "const reference use" is neither treated as initializing nor as using the local variable.
https://github.com/llvm/llvm-project/pull/147221
More information about the cfe-commits
mailing list