[cfe-commits] r67999 - in /cfe/trunk: lib/Sema/SemaDeclCXX.cpp lib/Sema/SemaOverload.cpp lib/Sema/SemaOverload.h test/SemaCXX/rval-references.cpp

Howard Hinnant hhinnant at apple.com
Wed Apr 1 12:20:31 PDT 2009


On Apr 1, 2009, at 3:14 PM, Sebastian Redl wrote:

>> http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#664
> I believe issue 664 is moot now that rvalue refs cannot bind to  
> lvalues.

Here's an updated test case for 664:

struct ref {
     explicit ref(int&& i): p(&i) { }
     int* p;
};

int&& forward(int&& i) {
     return static_cast<int&&>(i);
}

void f(int&& i) {
     ref r(forward(static_cast<int&&>(i)));
     // Here r.p is a dangling pointer, pointing to a defunct int  
temporary
}

You still don't want r.p to dangle.

-Howard




More information about the cfe-commits mailing list