This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [C++ PATCH] Fix up array initializations from compound literal (PR c++/40948)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Jason Merrill <jason at redhat dot com>
- Cc: Mark Mitchell <mark at codesourcery dot com>, gcc-patches at gcc dot gnu dot org
- Date: Tue, 4 Aug 2009 00:35:01 +0200
- Subject: Re: [C++ PATCH] Fix up array initializations from compound literal (PR c++/40948)
- References: <20090803171728.GZ4462@tyan-ft48-01.lab.bos.redhat.com> <4A77543D.1070001@redhat.com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Mon, Aug 03, 2009 at 05:18:53PM -0400, Jason Merrill wrote:
> On 08/03/2009 01:17 PM, Jakub Jelinek wrote:
>> * init.c (build_vec_init): Add CLEANUP_POINT_EXPR around
>> TRY_STMTS (try_block).
>
> I don't think this is right; I would expect it to mean that we destroy
> the compound literal right after we initialize it. I'll poke at this
> some more.
I think it is destroyed after it is copied.
struct M
{
M ();
~M ();
M (const M &);
};
void
foo ()
{
M m[2] = (M[2]) { M (), M () };
}
with the patch gives following. AFAICS D.2115 (the compund literal) is only
ever used inside of the TRY_BLOCK's TRY_STMTs, never later on.
D.2117 = &m[0];
D.2118 = D.2117;
D.2119 = 1;
try
{
M::M (&D.2115[0]);
M::M (&D.2115[1]);
try
{
D.2120 = &D.2115[0];
goto <D.2133>;
<D.2131>:
M::M (D.2118, D.2120);
D.2118 = D.2118 + 1;
D.2120 = D.2120 + 1;
D.2119 = D.2119 - 1;
<D.2133>:
D.2132 = D.2119 != -1;
if (D.2132 != 0) goto <D.2131>; else goto <D.2129>;
<D.2129>:
}
finally
{
// This is the compound literal cleanup
{
struct M * D.2116;
D.2116 = &D.2115[2];
<D.2126>:
if (D.2116 == &D.2115[0]) goto <D.2127>; else goto <D.2128>;
<D.2128>:
D.2116 = D.2116 + -1;
M::~M (D.2116);
goto <D.2126>;
<D.2127>:
}
}
}
catch
{
// And this is the build_vec_init TRY_BLOCK cleanup.
{
struct M * D.2122;
if (D.2117 != 0B) goto <D.2134>; else goto <D.2135>;
<D.2134>:
D.2136 = 1 - D.2119;
D.2137 = (long unsigned int) D.2136;
D.2122 = D.2117 + D.2137;
<D.2138>:
if (D.2122 == D.2117) goto <D.2139>; else goto <D.2140>;
<D.2140>:
D.2122 = D.2122 + -1;
M::~M (D.2122);
goto <D.2138>;
<D.2139>:
goto <D.2141>;
<D.2135>:
<D.2141>:
}
}
Jakub