This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

C++ PATCH for c++/86915, ICE with auto[]

This fixes ICE-on-invalid with an array of auto.  The problem was that
create_array_type_for_decl got null name, so the error call crashed.  We
need to handle this case as elsewhere in the function.

Bootstrapped/regtested on x86_64-linux, ok for trunk?

2018-08-11  Marek Polacek  <>

	PR c++/86915
	* decl.c (create_array_type_for_decl): Handle null name.

	* g++.dg/diagnostic/auto1.C: New test.

--- gcc/cp/decl.c
+++ gcc/cp/decl.c
@@ -9838,7 +9838,10 @@ create_array_type_for_decl (tree name, tree type, tree size)
      type-specifier, the program is ill-formed.  */
   if (type_uses_auto (type))
-      error ("%qD declared as array of %qT", name, type);
+      if (name)
+   error ("%qD declared as array of %qT", name, type);
+      else
+   error ("creating array of %qT", type);
       return error_mark_node;
--- gcc/testsuite/g++.dg/diagnostic/auto1.C
+++ gcc/testsuite/g++.dg/diagnostic/auto1.C
@@ -0,0 +1,4 @@
+// PR c++/86915
+// { dg-do compile { target c++17 } }
+template<auto [1]> struct S; // { dg-error "creating array of .auto." }

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]