Commit 1b6bfcd2 by Mark Mitchell Committed by Mark Mitchell

re PR c++/13478 (gcc uses wrong constructor to initialize a const reference)

	PR c++/13478
	* call.c (initialize_reference): Pass -1 for inner parameter to
	convert_like_real.

	PR c++/13478
	* g++.dg/init/ref10.C: New test.

From-SVN: r75983
parent a3fe7b56
2004-01-16 Mark Mitchell <mark@codesourcery.com> 2004-01-16 Mark Mitchell <mark@codesourcery.com>
PR c++/13478 PR c++/13478
* call.c (convert_like_real): Do not perform an additional * call.c (initialize_reference): Pass -1 for inner parameter to
direct-initialization when binding to a reference. convert_like_real.
2004-01-15 Giovanni Bajo <giovannibajo@gcc.gnu.org> 2004-01-15 Giovanni Bajo <giovannibajo@gcc.gnu.org>
......
...@@ -4068,7 +4068,8 @@ convert_like_real (tree convs, tree expr, tree fn, int argnum, int inner, ...@@ -4068,7 +4068,8 @@ convert_like_real (tree convs, tree expr, tree fn, int argnum, int inner,
conversion, but is not considered during overload resolution. conversion, but is not considered during overload resolution.
If the target is a class, that means call a ctor. */ If the target is a class, that means call a ctor. */
if (IS_AGGR_TYPE (totype) && inner >= 0) if (IS_AGGR_TYPE (totype)
&& (inner >= 0 || !lvalue_p (expr)))
{ {
expr = (build_temp expr = (build_temp
(expr, totype, (expr, totype,
...@@ -6250,7 +6251,10 @@ initialize_reference (tree type, tree expr, tree decl, tree *cleanup) ...@@ -6250,7 +6251,10 @@ initialize_reference (tree type, tree expr, tree decl, tree *cleanup)
else else
base_conv_type = NULL_TREE; base_conv_type = NULL_TREE;
/* Perform the remainder of the conversion. */ /* Perform the remainder of the conversion. */
expr = convert_like (conv, expr); expr = convert_like_real (conv, expr,
/*fn=*/NULL_TREE, /*argnum=*/0,
/*inner=*/-1,
/*issue_conversion_warnings=*/true);
if (!real_lvalue_p (expr)) if (!real_lvalue_p (expr))
{ {
tree init; tree init;
......
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