https://gcc.gnu.org/g:020abf25ff799b8070c41448d88959b573397583

commit 020abf25ff799b8070c41448d88959b573397583
Author: Sandra Loosemore <[email protected]>
Date:   Thu Jul 2 18:10:40 2026 +0000

    OpenMP: Fix ICE in libgomp testcase declare-mapper-10.f90
    
    This fix was originally included in OG15 commit 4c4064a5736d
    ("OpenMP/Fortran: Map intermediate array descriptors [PR120505]"),
    but not in the mainline version of that patch.  It's necessary to avoid
    a null pointer dereference in the libgomp testcase declare-mapper-10.f90.
    
    gcc/ChangeLog
            * gimplify.cc (omp_build_struct_sibling_lists): Avoid null
            pointer dereference from trying to move nodes that aren't
            associated with the base object.
    
    Co-authored-by: Paul-Antoine Arras <[email protected]>

Diff:
---
 gcc/gimplify.cc | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/gcc/gimplify.cc b/gcc/gimplify.cc
index 80ac032d9bd1..3d904f5fdd0e 100644
--- a/gcc/gimplify.cc
+++ b/gcc/gimplify.cc
@@ -13964,7 +13964,9 @@ omp_build_struct_sibling_lists (enum tree_code code,
          gcc_assert (TREE_CODE (base) == NOP_EXPR);
          base = build_fold_indirect_ref (base);
          tree *struct_node = struct_map_to_clause->get (base);
-         omp_siblist_move_node_after (c, cp, &OMP_CLAUSE_CHAIN (*struct_node));
+         if (struct_node)
+           omp_siblist_move_node_after (c, cp,
+                                        &OMP_CLAUSE_CHAIN (*struct_node));
        }
     }

Reply via email to