[Bug tree-optimization/97201] [11 Regression] ICE in location_wrapper_p at gcc/gcc/tree.h:4002 since r11-3410-g67aeddb785ddcc86

msebor at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Fri Sep 25 15:24:13 GMT 2020


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

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
             Status|NEW                         |ASSIGNED

--- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> ---
Ugh.  This is the result of the gratuitous difference in the representation of
zero-length arrays between C and C++.  The patch below fixes it though the
difference is a gotcha that will likely keep causing more problems down the
road (I don't think this isn't the first one).

diff --git a/gcc/cp/error.c b/gcc/cp/error.c
index ecb41e82d8c..59c915deb1f 100644
--- a/gcc/cp/error.c
+++ b/gcc/cp/error.c
@@ -951,8 +951,9 @@ dump_type_suffix (cxx_pretty_printer *pp, tree t, int
flags)
       if (tree dtype = TYPE_DOMAIN (t))
        {
          tree max = TYPE_MAX_VALUE (dtype);
-         /* Zero-length arrays have an upper bound of SIZE_MAX.  */
-         if (integer_all_onesp (max))
+         /* Zero-length arrays have a null upper bound in C++ and
+            SIZE_MAX in C.  */
+         if (!max || integer_all_onesp (max))
            pp_character (pp, '0');
          else if (tree_fits_shwi_p (max))
            pp_wide_integer (pp, tree_to_shwi (max) + 1);


More information about the Gcc-bugs mailing list