https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128386

--- Comment #3 from Ivan Lazaric <ivan.lazaric.gcc at gmail dot com> ---
Following patch seems to fix the 2 snippets:
```patch
 gcc/cp/cp-gimplify.cc | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/gcc/cp/cp-gimplify.cc b/gcc/cp/cp-gimplify.cc
index 51b40690559..ea92c975e08 100644
--- a/gcc/cp/cp-gimplify.cc
+++ b/gcc/cp/cp-gimplify.cc
@@ -2140,20 +2140,6 @@ cp_genericize_r (tree *stmt_p, int *walk_subtrees, void
*data)
                                     : OMP_CLAUSE_DEFAULT_PRIVATE);
              }
        }
-      if (sanitize_flags_p (SANITIZE_NULL | SANITIZE_ALIGNMENT |
SANITIZE_VPTR))
-       {
-         /* The point here is to not sanitize static initializers.  */
-         bool no_sanitize_p = wtd->no_sanitize_p;
-         wtd->no_sanitize_p = true;
-         for (tree decl = BIND_EXPR_VARS (stmt);
-              decl;
-              decl = DECL_CHAIN (decl))
-           if (VAR_P (decl)
-               && TREE_STATIC (decl)
-               && DECL_INITIAL (decl))
-             cp_walk_tree (&DECL_INITIAL (decl), cp_genericize_r, data, NULL);
-         wtd->no_sanitize_p = no_sanitize_p;
-       }
       if (flag_reflection)
        /* Adjust consteval-only vars in BIND_EXPR_VARS so that REFLECT_EXPR
           doesn't leak into the ME.  */
@@ -2176,6 +2162,20 @@ cp_genericize_r (tree *stmt_p, int *walk_subtrees, void
*data)
              }
            p = &DECL_CHAIN (*p);
          }
+      if (sanitize_flags_p (SANITIZE_NULL | SANITIZE_ALIGNMENT |
SANITIZE_VPTR))
+       {
+         /* The point here is to not sanitize static initializers.  */
+         bool no_sanitize_p = wtd->no_sanitize_p;
+         wtd->no_sanitize_p = true;
+         for (tree decl = BIND_EXPR_VARS (stmt);
+              decl;
+              decl = DECL_CHAIN (decl))
+           if (VAR_P (decl)
+               && TREE_STATIC (decl)
+               && DECL_INITIAL (decl))
+             cp_walk_tree (&DECL_INITIAL (decl), cp_genericize_r, data, NULL);
+         wtd->no_sanitize_p = no_sanitize_p;
+       }
       wtd->bind_expr_stack.safe_push (stmt);
       cp_walk_tree (&BIND_EXPR_BODY (stmt),
                    cp_genericize_r, data, NULL);
-- 
2.43.0
```

Reply via email to