public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-7087] analyzer: fix ICE on realloc of non-heap [PR104417]
@ 2022-02-07 23:33 David Malcolm
  0 siblings, 0 replies; only message in thread
From: David Malcolm @ 2022-02-07 23:33 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:0c04ac0e15830b94a9f1e0715d92a4a2558dda03

commit r12-7087-g0c04ac0e15830b94a9f1e0715d92a4a2558dda03
Author: David Malcolm <dmalcolm@redhat.com>
Date:   Mon Feb 7 14:00:55 2022 -0500

    analyzer: fix ICE on realloc of non-heap [PR104417]
    
    gcc/analyzer/ChangeLog:
            PR analyzer/104417
            * sm-taint.cc (tainted_allocation_size::tainted_allocation_size):
            Remove overzealous assertion.
            (tainted_allocation_size::emit): Likewise.
            (region_model::check_dynamic_size_for_taint): Likewise.
    
    gcc/testsuite/ChangeLog:
            PR analyzer/104417
            * gcc.dg/analyzer/pr104417.c: New test.
    
    Signed-off-by: David Malcolm <dmalcolm@redhat.com>

Diff:
---
 gcc/analyzer/sm-taint.cc                 | 9 ---------
 gcc/testsuite/gcc.dg/analyzer/pr104417.c | 7 +++++++
 2 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/gcc/analyzer/sm-taint.cc b/gcc/analyzer/sm-taint.cc
index 573a9124286..57a0ac684ab 100644
--- a/gcc/analyzer/sm-taint.cc
+++ b/gcc/analyzer/sm-taint.cc
@@ -496,9 +496,6 @@ public:
   : taint_diagnostic (sm, arg, has_bounds),
     m_mem_space (mem_space)
   {
-    gcc_assert (mem_space == MEMSPACE_STACK
-		|| mem_space == MEMSPACE_HEAP
-		|| mem_space == MEMSPACE_UNKNOWN);
   }
 
   const char *get_kind () const FINAL OVERRIDE
@@ -511,9 +508,6 @@ public:
     diagnostic_metadata m;
     /* "CWE-789: Memory Allocation with Excessive Size Value".  */
     m.add_cwe (789);
-    gcc_assert (m_mem_space == MEMSPACE_STACK
-		|| m_mem_space == MEMSPACE_HEAP
-		|| m_mem_space == MEMSPACE_UNKNOWN);
     // TODO: make use of m_mem_space
     if (m_arg)
       switch (m_has_bounds)
@@ -1055,9 +1049,6 @@ region_model::check_dynamic_size_for_taint (enum memory_space mem_space,
 					    const svalue *size_in_bytes,
 					    region_model_context *ctxt) const
 {
-  gcc_assert (mem_space == MEMSPACE_STACK
-	      || mem_space == MEMSPACE_HEAP
-	      || mem_space == MEMSPACE_UNKNOWN);
   gcc_assert (size_in_bytes);
   gcc_assert (ctxt);
 
diff --git a/gcc/testsuite/gcc.dg/analyzer/pr104417.c b/gcc/testsuite/gcc.dg/analyzer/pr104417.c
new file mode 100644
index 00000000000..41ea5dbd0c7
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/pr104417.c
@@ -0,0 +1,7 @@
+char eparr[1];
+
+void *
+warn_realloc_extern_ptrarr_offset (int i, int n)
+{
+  return __builtin_realloc (eparr + i, n); /* { dg-warning "'__builtin_realloc' called on unallocated object 'eparr'" } */
+}


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-02-07 23:33 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-07 23:33 [gcc r12-7087] analyzer: fix ICE on realloc of non-heap [PR104417] David Malcolm

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).