Commit 1ee26047 by Jason Merrill Committed by Jason Merrill

PR c++/79533 - C++17 ICE with temporary cast to reference

	* call.c (build_over_call): Conversion to a reference prevents copy
	elision.

From-SVN: r245538
parent 8b4aea73
2017-02-17 Jason Merrill <jason@redhat.com>
PR c++/79533 - C++17 ICE with temporary cast to reference
* call.c (build_over_call): Conversion to a reference prevents copy
elision.
2017-02-16 Jakub Jelinek <jakub@redhat.com>
Jason Merrill <jason@redhat.com>
......
......@@ -7955,7 +7955,14 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain)
/* Pull out the real argument, disregarding const-correctness. */
targ = arg;
while (CONVERT_EXPR_P (targ)
/* Strip the reference binding for the constructor parameter. */
if (CONVERT_EXPR_P (targ)
&& TREE_CODE (TREE_TYPE (targ)) == REFERENCE_TYPE)
targ = TREE_OPERAND (targ, 0);
/* But don't strip any other reference bindings; binding a temporary to a
reference prevents copy elision. */
while ((CONVERT_EXPR_P (targ)
&& TREE_CODE (TREE_TYPE (targ)) != REFERENCE_TYPE)
|| TREE_CODE (targ) == NON_LVALUE_EXPR)
targ = TREE_OPERAND (targ, 0);
if (TREE_CODE (targ) == ADDR_EXPR)
......
// PR c++/79533
struct S {
S();
S(const S&);
};
S f();
S s(static_cast<S const &>(f()));
// The static_cast prevents copy elision.
// { dg-final { scan-assembler "_ZN1SC1ERKS_" } }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment