Re: [PATCH] c++: Fix up assert in build_vec_init [PR126752]
Jason Merrill <[email protected]>
| Newsgroups | gmane.comp.gcc.patches |
|---|---|
| Message-ID | <[email protected]> |
On 8/18/26 3:41 AM, Jakub Jelinek wrote:
> Hi!
>
> The following testcase ICEs in an assert added by Marek in
> r15-6308. A subsequent change r15-6897 made the code added in
> the former commit no longer trigger on anything in the testsuite,
> including the initlist-array{23,24}.C tests added for it.
> Later on I've added an optimization in r16-343 so that cleanups
> clear rval instead of setting iterator to maxindex but missed
> this spot and nothing in the testsuite triggered it.
>
> The following patch adjusts the assert to what the r16-343 change
> does.
>
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk/16.3?
OK.
> 2026-08-17 Jakub Jelinek <[email protected]>
>
> PR c++/126752
> * init.cc (build_vec_init): Assert TREE_PURPOSE of the
> last *cleanup_flags element is rval rather than iterator.
>
> * g++.dg/cpp0x/initlist-array25.C: New test.
>
> --- gcc/cp/init.cc.jj 2026-06-25 10:03:50.807436517 +0200
> +++ gcc/cp/init.cc 2026-08-17 11:46:04.686289531 +0200
> @@ -5365,7 +5365,7 @@ build_vec_init (tree base, tree maxindex
> && !vec_safe_is_empty (*cleanup_flags))
> {
> auto l = (*cleanup_flags)->last ();
> - gcc_assert (TREE_PURPOSE (l) == iterator);
> + gcc_assert (TREE_PURPOSE (l) == rval);
> (*cleanup_flags)->pop ();
> }
> tree const_init = build_constructor (atype, const_vec);
> --- gcc/testsuite/g++.dg/cpp0x/initlist-array25.C.jj 2026-08-17 11:43:57.918910197 +0200
> +++ gcc/testsuite/g++.dg/cpp0x/initlist-array25.C 2026-08-17 11:43:23.403351461 +0200
> @@ -0,0 +1,12 @@
> +// PR c++/126752
> +// { dg-do compile { target c++11 } }
> +
> +struct A {
> + struct B { constexpr B () {} };
> + struct C { ~C (); B c; };
> + struct D : private C {};
> + struct E { E (); };
> + struct F { D f {}; };
> + struct G { F g[1] {}; E h; };
> + void foo () { G {}; }
> +};
>
> Jakub
>