[clang] [clang][ExprConst] Reject field access with nullptr base (PR #113885)
Richard Smith via cfe-commits
cfe-commits at lists.llvm.org
Mon Oct 28 17:20:44 PDT 2024
================
@@ -1703,7 +1703,7 @@ namespace {
bool checkNullPointerDiagnosingWith(const GenDiagType &GenDiag) {
if (Designator.Invalid)
return false;
- if (IsNullPtr) {
+ if (getLValueBase().isNull()) {
----------------
zygoloid wrote:
Oh, I see. We're adjusting the offset *before* we call `addDecl`. I think this would be better fixed by reversing the order in which we do those steps -- first `addDecl` and then adjust the offset. A null base isn't necessarily a null pointer, so checking for a null base here seems wrong (but only in the weird case of a zero integer cast to a non-null pointer value, which we should only accept in constant-folding mode, not when properly evaluating).
https://github.com/llvm/llvm-project/pull/113885
More information about the cfe-commits
mailing list