On Tue, Nov 26, 2019 at 04:58:01PM -0500, Jason Merrill wrote: > Hmm, we shouldn't have any PLACEHOLDER_EXPR under a RANGE_EXPR; if we did, > any references to its address would end up all referring to the first > element of the range, which would be wrong. How about skipping RANGE_EXPR > in replace_placeholders_r?
So like this? Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2019-11-27 Jakub Jelinek <ja...@redhat.com> PR c++/92524 * tree.c (replace_placeholders_r): Don't walk constructor elts with RANGE_EXPR indexes. * g++.dg/cpp0x/pr92524.C: New test. --- gcc/cp/tree.c.jj 2019-11-26 23:09:55.904101392 +0100 +++ gcc/cp/tree.c 2019-11-26 23:13:14.308070759 +0100 @@ -3144,6 +3144,11 @@ replace_placeholders_r (tree* t, int* wa tree type = TREE_TYPE (*valp); tree subob = obj; + /* Elements with RANGE_EXPR index shouldn't have any + placeholders in them. */ + if (ce->index && TREE_CODE (ce->index) == RANGE_EXPR) + continue; + if (TREE_CODE (*valp) == CONSTRUCTOR && AGGREGATE_TYPE_P (type)) { --- gcc/testsuite/g++.dg/cpp0x/pr92524.C.jj 2019-11-26 23:09:46.810240310 +0100 +++ gcc/testsuite/g++.dg/cpp0x/pr92524.C 2019-11-26 23:09:46.810240310 +0100 @@ -0,0 +1,12 @@ +// PR c++/92524 +// { dg-do compile { target c++11 } } + +struct A { char a = '*'; }; +struct B { A b[64]; }; + +void +foo () +{ + A a; + B{a}; +} Jakub