[Bug c++/86836] internal compiler error on structured bindings with shadow parameter on templated function
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86836 Jakub Jelinek changed: What|Removed |Added Status|ASSIGNED|RESOLVED Resolution|--- |FIXED --- Comment #11 from Jakub Jelinek --- Fixed for 8.3+ too. As it is ice-on-invalid-code, not going to backport further.
[Bug c++/86836] internal compiler error on structured bindings with shadow parameter on templated function
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86836 --- Comment #10 from Jakub Jelinek --- Author: jakub Date: Wed Sep 5 07:20:31 2018 New Revision: 264105 URL: https://gcc.gnu.org/viewcvs?rev=264105&root=gcc&view=rev Log: Backported from mainline 2018-08-08 Jakub Jelinek PR c++/86836 * pt.c (tsubst_expr): For structured bindings, call tsubst_decomp_names before tsubst_init, not after it. * g++.dg/cpp1z/decomp46.C: New test. Added: branches/gcc-8-branch/gcc/testsuite/g++.dg/cpp1z/decomp46.C Modified: branches/gcc-8-branch/gcc/cp/ChangeLog branches/gcc-8-branch/gcc/cp/pt.c branches/gcc-8-branch/gcc/testsuite/ChangeLog
[Bug c++/86836] internal compiler error on structured bindings with shadow parameter on templated function
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86836 Richard Biener changed: What|Removed |Added Known to work||9.0 --- Comment #9 from Richard Biener --- Fixed on trunk(?). Is this a regression?
[Bug c++/86836] internal compiler error on structured bindings with shadow parameter on templated function
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86836 --- Comment #8 from Jakub Jelinek --- Author: jakub Date: Wed Aug 8 08:32:51 2018 New Revision: 263391 URL: https://gcc.gnu.org/viewcvs?rev=263391&root=gcc&view=rev Log: PR c++/86836 * pt.c (tsubst_expr): For structured bindings, call tsubst_decomp_names before tsubst_init, not after it. * g++.dg/cpp1z/decomp46.C: New test. Added: trunk/gcc/testsuite/g++.dg/cpp1z/decomp46.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/pt.c trunk/gcc/testsuite/ChangeLog
[Bug c++/86836] internal compiler error on structured bindings with shadow parameter on templated function
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86836 Jakub Jelinek changed: What|Removed |Added Status|NEW |ASSIGNED Assignee|unassigned at gcc dot gnu.org |jakub at gcc dot gnu.org --- Comment #7 from Jakub Jelinek --- Created attachment 44499 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=44499&action=edit gcc9-pr86836.patch Actually, this seems to work, just tsubst_decomp_names before trying to tsubst_init the initializer; for valid code it should make no difference, because the initializer shouldn't refer to the decomp names, but for invalid code it matters.
[Bug c++/86836] internal compiler error on structured bindings with shadow parameter on templated function
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86836 Jakub Jelinek changed: What|Removed |Added CC||jason at gcc dot gnu.org --- Comment #6 from Jakub Jelinek --- I've tried to defer the assert until after cp_finish_decl: --- pt.c.jj12018-07-31 23:57:23.0 +0200 +++ pt.c2018-08-03 11:11:41.384454435 +0200 @@ -16555,10 +16555,7 @@ tsubst_decomp_names (tree decl, tree pat decl2 = DECL_CHAIN (decl2)) { if (TREE_TYPE (decl2) == error_mark_node && *cnt == 0) - { - gcc_assert (errorcount); - return error_mark_node; - } + return error_mark_node; (*cnt)++; gcc_assert (DECL_DECOMP_BASE (decl2) == pattern_decl); gcc_assert (DECL_HAS_VALUE_EXPR_P (decl2)); @@ -16572,7 +16569,6 @@ tsubst_decomp_names (tree decl, tree pat DECL_TEMPLATE_INSTANTIATED (decl3) = 1; else { - gcc_assert (errorcount); decl = error_mark_node; continue; } @@ -16582,10 +16578,7 @@ tsubst_decomp_names (tree decl, tree pat else if (decl != error_mark_node && DECL_CHAIN (decl3) != prev && decl != prev) - { - gcc_assert (errorcount); - decl = error_mark_node; - } + decl = error_mark_node; else prev = decl3; } @@ -16770,6 +16763,8 @@ tsubst_expr (tree t, tree args, tsubst_f cp_finish_decl (decl, init, const_init, NULL_TREE, 0); if (ndecl != error_mark_node) cp_finish_decomp (ndecl, first, cnt); + else + gcc_assert (errorcount); } else cp_finish_decl (decl, init, const_init, NULL_TREE, 0); @@ -16813,9 +16808,13 @@ tsubst_expr (tree t, tree args, tsubst_f tree decomp_first = NULL_TREE; unsigned decomp_cnt = 0; if (VAR_P (decl) && DECL_DECOMPOSITION_P (decl)) - decl = tsubst_decomp_names (decl, RANGE_FOR_DECL (t), args, - complain, in_decl, - &decomp_first, &decomp_cnt); + { + decl = tsubst_decomp_names (decl, RANGE_FOR_DECL (t), args, + complain, in_decl, + &decomp_first, &decomp_cnt); + if (decl == error_mark_node) + gcc_assert (errorcount); + } if (processing_template_decl) { but that doesn't help, the bug isn't diagnosed in this case either. For some reason, the orig decomp VAR_DECL is tsubsted to the PARM_DECL rather than a new VAR_DECL representing the structured binding id, and thus also cp_finish_decl succeeds. Giving up here.
[Bug c++/86836] internal compiler error on structured bindings with shadow parameter on templated function
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86836 Jakub Jelinek changed: What|Removed |Added CC||jakub at gcc dot gnu.org --- Comment #5 from Jakub Jelinek --- Without templates: struct A { int operator*(); void operator++(); bool operator!=(A); }; class map { public: A begin(); A end(); }; void mergemap(map orig, map toadd) { for (auto p : toadd) auto [orig] = orig; } int main() { map x, y; mergemap(x, y); } this is rejected with: pr86836-2.C: In function ‘void mergemap(map, map)’: pr86836-2.C:14:19: error: use of ‘orig’ before deduction of ‘auto’ auto [orig] = orig; ^~~~
[Bug c++/86836] internal compiler error on structured bindings with shadow parameter on templated function
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86836 --- Comment #4 from Marek Polacek --- commit 357b96452a5fc70011df4f27b5d4dffc5e2f2603 Author: jason Date: Tue Nov 15 05:22:28 2016 + Various C++17 decomposition fixes. * tree.c (bitfield_p): New. * cp-tree.h: Declare it. * typeck.c (cxx_sizeof_expr, cxx_alignof_expr) (cp_build_addr_expr_1): Use it instead of DECL_C_BIT_FIELD. * decl.c (cp_finish_decomp): Look through reference. Always SET_DECL_DECOMPOSITION_P. * semantics.c (finish_decltype_type): Adjust decomposition handling. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@242408 138bc75d-0d04-0410-961f-82ee72b054a4
[Bug c++/86836] internal compiler error on structured bindings with shadow parameter on templated function
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86836 Marek Polacek changed: What|Removed |Added Keywords||ice-on-invalid-code --- Comment #3 from Marek Polacek --- struct A { int operator*(); void operator++(); bool operator!=(A); }; template class map { public: A begin(); A end(); }; template void mergemap(map orig, map toadd) { for (auto p : toadd) auto [orig] = orig; } int main() { map x, y; mergemap(x, y); }
[Bug c++/86836] internal compiler error on structured bindings with shadow parameter on templated function
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86836 Marek Polacek changed: What|Removed |Added Status|UNCONFIRMED |NEW Last reconfirmed||2018-08-02 CC||mpolacek at gcc dot gnu.org Ever confirmed|0 |1 --- Comment #2 from Marek Polacek --- Confirmed, will reduce.
[Bug c++/86836] internal compiler error on structured bindings with shadow parameter on templated function
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86836 --- Comment #1 from Christian Shelton --- Created attachment 44496 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=44496&action=edit preprocessed source