re PR c++/35548 (g++ 4.3 miscompile this simple program)

PR c++/35548
        * call.c (reference_binding): Check LOOKUP_NO_TEMP_BIND when binding
        a temp directly to a reference as per DR391.

From-SVN: r133299
This commit is contained in:
Jason Merrill 2008-03-17 22:52:34 -04:00 committed by Jason Merrill
parent a5728e4006
commit 3d574e5b1f
4 changed files with 36 additions and 1 deletions

View File

@ -1,3 +1,9 @@
2008-03-17 Jason Merrill <jason@redhat.com>
PR c++/35548
* call.c (reference_binding): Check LOOKUP_NO_TEMP_BIND when binding
a temp directly to a reference as per DR391.
2008-03-12 Richard Guenther <rguenther@suse.de>
PR c++/35469

View File

@ -1145,7 +1145,8 @@ reference_binding (tree rto, tree rfrom, tree expr, bool c_cast_p, int flags)
const and rvalue references to rvalues of compatible class type. */
if (compatible_p
&& (lvalue_p
|| ((CP_TYPE_CONST_NON_VOLATILE_P(to) || TYPE_REF_IS_RVALUE (rto))
|| (!(flags & LOOKUP_NO_TEMP_BIND)
&& (CP_TYPE_CONST_NON_VOLATILE_P(to) || TYPE_REF_IS_RVALUE (rto))
&& CLASS_TYPE_P (from))))
{
/* [dcl.init.ref]

View File

@ -1,3 +1,8 @@
2008-03-17 Jason Merrill <jason@redhat.com>
PR c++/35548
* g++.dg/init/ref16.C: New testcase.
2008-03-17 Richard Guenther <rguenther@suse.de>
PR tree-optimization/19637

View File

@ -0,0 +1,23 @@
// PR c++/35548
// { dg-do run }
int c;
struct A
{
A() { ++c; }
A(const A&) { ++c; }
~A() { --c; }
};
A f()
{
return A();
}
int i;
const A* ap;
int main()
{
const A& ar = i ? *ap : f();
return (c == 0);
}