https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98969
Martin Sebor <msebor at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|unassigned at gcc dot gnu.org |msebor at gcc dot gnu.org Target Milestone|--- |11.0 Status|NEW |ASSIGNED Keywords|ice-on-invalid-code |ice-on-valid-code --- Comment #2 from Martin Sebor <msebor at gcc dot gnu.org> --- The following avoids the ICE: diff --git a/gcc/c-family/c-pretty-print.c b/gcc/c-family/c-pretty-print.c index 2095d4badf7..da4a8b5defd 100644 --- a/gcc/c-family/c-pretty-print.c +++ b/gcc/c-family/c-pretty-print.c @@ -1989,7 +1989,9 @@ print_mem_ref (c_pretty_printer *pp, tree e) } tree access_type = TREE_TYPE (e); - tree arg_type = TREE_TYPE (TREE_TYPE (arg)); + tree arg_type = TREE_TYPE (arg); + if (POINTER_TYPE_P (arg)) + arg_type = TREE_TYPE (arg_type); if (tree access_size = TYPE_SIZE_UNIT (access_type)) if (byte_off != 0 && TREE_CODE (access_size) == INTEGER_CST and results in: pr98969.c: In function ‘_round_2_cb’: pr98969.c:14:14: warning: argument 1 null where non-null expected [-Wnonnull] 14 | bb->expr = strdup ((const char *) 0); | ^~~~~~ pr98969.c:7:1: note: in a call to function ‘strdup’ declared ‘nonnull’ 7 | strdup (const char *); | ^~~~~~ pr98969.c:15:1: warning: leak of ‘*(struct TYPE_14__ *)_round_2_cb_n_0.expr’ [CWE-401] [-Wanalyzer-malloc-leak] 15 | } | ^ ‘_round_2_cb’: events 1-2 | | 14 | bb->expr = strdup ((const char *) 0); | | ^~~~~~~~~~~~~~~~~~~~~~~~~ | | | | | (1) allocated here | 15 | } | | ~ | | | | | (2) ‘*(struct TYPE_14__ *)_round_2_cb_n_0.expr’ leaks here; was allocated at (1) | The test case is undefined but syntactically valid thus ice-on-valid-code.