A typo in maybe_warn_alloc_args_overflow() has it compare the address
of an array for equality to null when it actually means to compare
the value of the array's element.  This is apparently caught by
Converity (and Jason who pointed it out to me -- thanks again).
In r12-3268 I've pushed the change below to fix this.  I'm testing
an enhancement to -Waddress to let GCC detect it as well.

Martin

commit r12-3268-gb3aa3288a958a75744df256d70e7f8e90ccab724
Author: Martin Sebor <mse...@redhat.com>
Date:   Tue Aug 31 11:16:37 2021 -0600

    Avoid valid Coverity warning for comparing array to zero.

* gimple-ssa-warn-access.cc (maybe_warn_alloc_args_overflow): Test
            pointer element for equality to zero, not that of the cotaining
            array.

Diff:
---
 gcc/gimple-ssa-warn-access.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/gimple-ssa-warn-access.cc b/gcc/gimple-ssa-warn-access.cc
index 5df97a6473a..5a359587ed3 100644
--- a/gcc/gimple-ssa-warn-access.cc
+++ b/gcc/gimple-ssa-warn-access.cc
@@ -2433,7 +2433,7 @@ maybe_warn_alloc_args_overflow (gimple *stmt, const tree args[2],
        }
     }

-  if (!argrange[0])
+  if (!argrange[0][0])
     return;

   /* For a two-argument alloc_size, validate the product of the two


Reply via email to