[gcc r17-3398] ipa/126930 - defend against non-pointers in ptr_deref_may_alias_global_p

Richard Biener via Gcc-cvs <[email protected]>
Newsgroups gmane.comp.gcc.cvs
Message-ID <[email protected]>
https://gcc.gnu.org/g:b6ff1ae5bada420faba2083f27c665274909ee19

commit r17-3398-gb6ff1ae5bada420faba2083f27c665274909ee19
Author: Richard Biener <[email protected]>
Date:   Tue Aug 18 14:40:14 2026 +0200

    ipa/126930 - defend against non-pointers in ptr_deref_may_alias_global_p
    
    The following for consistency reasons defends against accessing
    SSA_NAME_PTR_INFO on non-pointers which might then instead
    access range info.
    
            PR ipa/126930
            * tree-ssa-alias.cc (ptr_deref_may_alias_global_p): Guard
            against non-pointers.
            (ptr_deref_may_alias_auto_p): Likewise.

Diff:
---
 gcc/tree-ssa-alias.cc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/tree-ssa-alias.cc b/gcc/tree-ssa-alias.cc
index 1d10f6dbd973..7fc87b3b9446 100644
--- a/gcc/tree-ssa-alias.cc
+++ b/gcc/tree-ssa-alias.cc
@@ -224,7 +224,7 @@ ptr_deref_may_alias_global_p (tree ptr, bool escaped_local_p)
 
   /* If we end up with a pointer constant here that may point
      to global memory.  */
-  if (TREE_CODE (ptr) != SSA_NAME)
+  if (TREE_CODE (ptr) != SSA_NAME || !POINTER_TYPE_P (TREE_TYPE (ptr)))
     return true;
 
   pi = SSA_NAME_PTR_INFO (ptr);
@@ -248,7 +248,7 @@ ptr_deref_may_alias_auto_p (tree ptr)
 
   /* If we end up with a pointer constant here that may point
      to local stack memory.  */
-  if (TREE_CODE (ptr) != SSA_NAME)
+  if (TREE_CODE (ptr) != SSA_NAME || !POINTER_TYPE_P (TREE_TYPE (ptr)))
     return true;
 
   pi = SSA_NAME_PTR_INFO (ptr);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.