Bug 56701 - [C++11] The *this* pointer fails to bind to rvalue reference to pointer type
[C++11] The *this* pointer fails to bind to rvalue reference to pointer type
Status: RESOLVED FIXED
Product: gcc
Classification: Unclassified
Component: c++
4.8.0
: P3 normal
: 4.9.0
Assigned To: Jason Merrill
: rejects-valid
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-03-23 22:38 UTC by Jesse Good
Modified: 2013-03-28 20:05 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2013-03-24 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jesse Good 2013-03-23 22:38:14 UTC
The following fails to compile with gcc 4.8.0:

struct A
{
  void f(){ A*&& a = this; }
};
int main(){}

Error messages:
error: invalid initialization of reference of type 'A*&&' from expression of type 'A* const'
void f(){ A*&& a = this; }


According to 9.3.2p1, the this pointer is a prvalue of type A*, not A* const as the error message suggests.
Comment 1 Jonathan Wakely 2013-03-24 20:12:51 UTC
Confirmed, the reference should be bound to a temporary of type A*
Comment 2 Jason Merrill 2013-03-28 20:05:11 UTC
Fixed for 4.9.