https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84972
Marek Polacek <mpolacek at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |mpolacek at gcc dot gnu.org --- Comment #3 from Marek Polacek <mpolacek at gcc dot gnu.org> --- Sorry, I already have a patch: 2018-03-20 Marek Polacek <pola...@redhat.com> PR c++/84972 * c-common.c (complete_array_type): Bail for bogus MAXINDEX. * g++.dg/parse/crash68.C: New test. diff --git gcc/c-family/c-common.c gcc/c-family/c-common.c index e1df1d3b73b..108d5f8f2d8 100644 --- gcc/c-family/c-common.c +++ gcc/c-family/c-common.c @@ -6332,6 +6332,11 @@ complete_array_type (tree *ptype, tree initial_value, bool do_default) if ((*v)[0].index) maxindex = (*v)[0].index, fold_p = true; + /* If we can't do anything useful with the index, + signal failure. */ + if (maxindex == error_mark_node) + return 1; + curindex = maxindex; for (cnt = 1; vec_safe_iterate (v, cnt, &ce); cnt++) diff --git gcc/testsuite/g++.dg/parse/crash68.C gcc/testsuite/g++.dg/parse/crash68.C index e69de29bb2d..b8c47ba155c 100644 --- gcc/testsuite/g++.dg/parse/crash68.C +++ gcc/testsuite/g++.dg/parse/crash68.C @@ -0,0 +1,4 @@ +// PR c++/84972 +// { dg-additional-options "-w" } + +char a[] ({.a = 0}); // { dg-error "" }