C++ PATCH: PR 16405
Jason Merrill
jason@redhat.com
Thu Dec 23 18:33:00 GMT 2004
On Thu, 23 Dec 2004 00:12:45 -0800, Mark Mitchell <mark@codesourcery.com> wrote:
> This patch fixes a C++ optimization problem. In the case of the code
> in the attached test case, the compiler was generating a temporary for
> "a + b", as expected. Then, for the call to the (implicitly declared)
> assignment operator "T::operator=", we generated another temporary, to
> bind to the const reference parameter to the assignment operator.
> That's permitted, but silly.
>
> The problem was that the front-end generates:
>
> memcpy (&a, *(const T*)&<target_expr operator+(b, c)>, sizeof (T))
>
> The gimplifier could not see through the INDIRECT_REF/ADDR_EXPR
> combination to find the underlying TARGET_EXPR, and so generate a
> temporary for it.
I don't see where the second temporary you mention is coming from. I would
expect the gimplifier to generate a temporary to store the address of the
TARGET_EXPR temporary, but that's just a scalar.
Jason
More information about the Gcc-patches
mailing list