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

            Bug ID: 101874
           Summary: [12 Regression] ICE with auto specifier for arrays
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Keywords: ice-on-invalid-code
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: reichelt at gcc dot gnu.org
                CC: mpolacek at gcc dot gnu.org
  Target Milestone: ---

The two testcases from PR 60628 and PR 60629 (originally fixed in GCC 4.8.3)
started triggering ICEs again on trunk.

PR 60628:
===============================
#include <initializer_list>

void foo(int i)
{
  auto x[i] = { 0 };
}
===============================

PR 60629:
===============================
void foo(int i)
{
  auto(*p)[i] = (int(*)[i])0;
}
===============================

They also crash in the same functions as before:
tsubst_copy and unify_array_domain
which are eventually called from do_auto_deduction:

PR60628.cc: In function 'void foo(int)':
PR60628.cc:5:11: internal compiler error: in tsubst_copy, at cp/pt.c:17243
    5 |   auto x[i] = { 0 };
      |           ^
0x6e7512 tsubst_copy
        ../../gcc/gcc/cp/pt.c:17243
0xaf1eb4 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
        ../../gcc/gcc/cp/pt.c:20870
0xaf3651 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
        ../../gcc/gcc/cp/pt.c:19639
0xaf46d9 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
        ../../gcc/gcc/cp/pt.c:19815
0xafd357 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        ../../gcc/gcc/cp/pt.c:19092
0xb0f64f tsubst(tree_node*, tree_node*, int, tree_node*)
        ../../gcc/gcc/cp/pt.c:15475
0xb0f6d3 tsubst(tree_node*, tree_node*, int, tree_node*)
        ../../gcc/gcc/cp/pt.c:15920
0xaedaff do_auto_deduction(tree_node*, tree_node*, tree_node*, int,
auto_deduction_context, tree_node*, int)
        ../../gcc/gcc/cp/pt.c:29561
[etc.]


PR60629.cc: In function 'void foo(int)':
PR60629.cc:3:28: internal compiler error: in unify_array_domain, at
cp/pt.c:23278
    3 |   auto(*p)[i] = (int(*)[i])0;
      |                            ^
0x6f380d unify_array_domain
        ../../gcc/gcc/cp/pt.c:23278
0xb0b138 unify
        ../../gcc/gcc/cp/pt.c:23848
0xb0abc9 unify
        ../../gcc/gcc/cp/pt.c:23829
0xb081f0 unify_one_argument
        ../../gcc/gcc/cp/pt.c:22107
0xb154da type_unification_real
        ../../gcc/gcc/cp/pt.c:22226
0xaecaff do_auto_deduction(tree_node*, tree_node*, tree_node*, int,
auto_deduction_context, tree_node*, int)
        ../../gcc/gcc/cp/pt.c:29637
[etc.]


I suspect that the regression was caused by Marek's commit r12-1933.
Marek, could you please have a look?


Unfortunately, the testsuite did not show the regression because it doesn't
contain the original tescases. The second one wasn't added because it was
deemed a duplicate (which makes sense as both ICEs reappered together).

The first testcase was added as g++.dg/cpp0x/auto42.C, but with a subtle
change: 
  auto x[1] = { 0 };
instead of
  auto x[i] = { 0 };
The version in the testsuite actually never showed the ICE.
So we should probably add the original version to the test.

Reply via email to