Commit 952e24fe by Jason Merrill Committed by Jason Merrill

re PR c++/36744 ([C++0x] function modifying argument received by-value affects…

re PR c++/36744 ([C++0x] function modifying argument received by-value affects caller's variable when passed as rvalue)

        PR c++/36744
        * tree.c (lvalue_p_1): Condition rvalue ref handling on
        treat_class_rvalues_as_lvalues, too.

From-SVN: r144091
parent 1d428010
2009-02-10 Jason Merrill <jason@redhat.com>
PR c++/36744
* tree.c (lvalue_p_1): Condition rvalue ref handling on
treat_class_rvalues_as_lvalues, too.
2009-02-10 Paolo Carlini <paolo.carlini@oracle.com> 2009-02-10 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/34397 PR c++/34397
......
...@@ -82,7 +82,12 @@ lvalue_p_1 (tree ref, ...@@ -82,7 +82,12 @@ lvalue_p_1 (tree ref,
&& TREE_CODE (ref) != PARM_DECL && TREE_CODE (ref) != PARM_DECL
&& TREE_CODE (ref) != VAR_DECL && TREE_CODE (ref) != VAR_DECL
&& TREE_CODE (ref) != COMPONENT_REF) && TREE_CODE (ref) != COMPONENT_REF)
return clk_none; {
if (CLASS_TYPE_P (TREE_TYPE (TREE_TYPE (ref))))
return treat_class_rvalues_as_lvalues ? clk_class : clk_none;
else
return clk_none;
}
/* lvalue references and named rvalue references are lvalues. */ /* lvalue references and named rvalue references are lvalues. */
return clk_ordinary; return clk_ordinary;
......
2009-02-11 Jason Merrill <jason@redhat.com>
PR c++/36744
* g++.dg/cpp0x/rv9p.C: New test.
2009-02-10 Eric Botcazou <ebotcazou@adacore.com> 2009-02-10 Eric Botcazou <ebotcazou@adacore.com>
* gnat.dg/aliasing3.adb: New test. * gnat.dg/aliasing3.adb: New test.
......
// PR c++/36744
// { dg-options "-std=c++0x" }
// { dg-do run }
struct S
{
S(): i(2) {}
S(S const&s): i(s.i) {}
int i;
};
void f(S x) { x.i = 0; }
extern "C" void abort (void);
int main()
{
S y;
f(static_cast<S&&>(y));
if (y.i != 2)
abort ();
return 0;
}
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