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

PR c++/13478
	* call.c (convert_like_real): Do not perform an additional
	direct-initialization when binding to a reference.

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

From-SVN: r75979
This commit is contained in:
Mark Mitchell 2004-01-16 16:59:30 +00:00 committed by Mark Mitchell
parent 1620182354
commit ab8ffc795c
4 changed files with 26 additions and 2 deletions

View File

@ -1,3 +1,9 @@
2004-01-16 Mark Mitchell <mark@codesourcery.com>
PR c++/13478
* call.c (convert_like_real): Do not perform an additional
direct-initialization when binding to a reference.
2004-01-15 Giovanni Bajo <giovannibajo@gcc.gnu.org>
PR c++/13407

View File

@ -4068,8 +4068,7 @@ convert_like_real (tree convs, tree expr, tree fn, int argnum, int inner,
conversion, but is not considered during overload resolution.
If the target is a class, that means call a ctor. */
if (IS_AGGR_TYPE (totype)
&& (inner >= 0 || !lvalue_p (expr)))
if (IS_AGGR_TYPE (totype) && inner >= 0)
{
expr = (build_temp
(expr, totype,

View File

@ -1,3 +1,8 @@
2004-01-16 Mark Mitchell <mark@codesourcery.com>
PR c++/13478
* g++.dg/init/ref10.C: New test.
2004-01-15 Giovanni Bajo <giovannibajo@gcc.gnu.org>
PR c++/13407

View File

@ -0,0 +1,14 @@
// PR c++/13478
struct A {};
struct B : protected A {
B() {};
B(const A& ) {};
private:
B(const B& ) {};
};
void foo(const A* ap)
{
const B& br = *ap;
}