Here we crash when using -fsanitize=address -fdump-tree-sanopt because
the dumping code uses IDENTIFIER_POINTER on a null DECL_NAME.  Instead,
we can print "<anonymous>" in such a case.  Or we could avoid printing
that diagnostic altogether.

I don't think this warrants a testcase.

Tested x86_64-linux, ok for trunk and 9?

2020-01-25  Marek Polacek  <pola...@redhat.com>

        PR tree-optimization/93436
        * sanopt.c (sanitize_rewrite_addressable_params): Avoid crash on
        null DECL_NAME.
---
 gcc/sanopt.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/gcc/sanopt.c b/gcc/sanopt.c
index 619aae45a15..63fd68d4ad1 100644
--- a/gcc/sanopt.c
+++ b/gcc/sanopt.c
@@ -1176,7 +1176,9 @@ sanitize_rewrite_addressable_params (function *fun)
          if (dump_file)
            fprintf (dump_file,
                     "Rewriting parameter whose address is taken: %s\n",
-                    IDENTIFIER_POINTER (DECL_NAME (arg)));
+                    (DECL_NAME (arg)
+                     ? IDENTIFIER_POINTER (DECL_NAME (arg))
+                     : "<anonymous>"));
 
          SET_DECL_PT_UID (var, DECL_PT_UID (arg));
 

base-commit: 05107d4e4ccd11ecc8712d6e271fcb4b5f17060f
-- 
Marek Polacek • Red Hat, Inc. • 300 A St, Boston, MA

Reply via email to