https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109319
--- Comment #7 from CVS Commits ---
The releases/gcc-12 branch has been updated by Jakub Jelinek
:
https://gcc.gnu.org/g:6a5c0588ac00f6f55ae7ed2bb791e7e119a01c43
commit r12-9425-g6a5c0588ac00f6f55ae7ed2bb791e7e119a01c43
Author: Jakub Jelinek
Date: Thu Mar 30 23:08:25 2023 +0200
c++: Fix up ICE in build_min_non_dep_op_overload [PR109319]
The following testcase ICEs, because grok_array_decl during
processing_template_decl handling of a non-dependent subscript
emits a -Wcomma-subscript pedwarn, we decide to pass to the
single index argument the index expressions as if it was wrapped
with () around it, but then when preparing it for later instantiation
we don't actually take that into account and ICE on a mismatch of
number of index arguments (the overload expects a single index,
testcase has two index expressions in this case).
For non-dependent subscript which are builtin subscripts we also
emit the same pedwarn and don't ICE, but emit the same pedwarn
again whenever we instantiate it, which is also IMHO undesirable,
it is enough to warn once during parsing the template.
The following patch fixes it by turning even the original index expressions
(those which didn't go through make_args_non_dependent) into a single
index using comma expression(s).
2023-03-30 Jakub Jelinek
PR c++/109319
* decl2.cc (grok_array_decl): After emitting a pedwarn for
-Wcomma-subscript, if processing_template_decl set orig_index_exp
to compound expr from orig_index_exp_list.
* g++.dg/cpp23/subscript14.C: New test.
(cherry picked from commit c016887c91a79d67b6a3c7e19b9219f5ab1e2a4d)