On Thu, Mar 28, 2013 at 2:14 PM, Jason Merrill <ja...@redhat.com> wrote:
> When 'this' appears in an expression, it should be an rvalue rather than a
> const lvalue; in C++11, the distinction matters.

And likewise for &*this.

Tested x86_64-pc-linux-gnu, applying to trunk.
commit 9258170ab23137c255e656ac76c96736a2e175d6
Author: Jason Merrill <ja...@redhat.com>
Date:   Tue Aug 9 00:32:10 2016 -0400

        PR c++/56701 - wrong type of &*this
    
        * typeck.c (cp_build_addr_expr_1): Remove special *this handling.

diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index 78d443b..bedc453 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -5626,11 +5626,6 @@ cp_build_addr_expr_1 (tree arg, bool strict_lvalue, 
tsubst_flags_t complain)
   /* Let &* cancel out to simplify resulting code.  */
   if (INDIRECT_REF_P (arg))
     {
-      /* We don't need to have `current_class_ptr' wrapped in a
-        NON_LVALUE_EXPR node.  */
-      if (arg == current_class_ref)
-       return current_class_ptr;
-
       arg = TREE_OPERAND (arg, 0);
       if (TREE_CODE (TREE_TYPE (arg)) == REFERENCE_TYPE)
        {
diff --git a/gcc/testsuite/g++.dg/cpp0x/rv-this2.C 
b/gcc/testsuite/g++.dg/cpp0x/rv-this2.C
new file mode 100644
index 0000000..fcfd265
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/rv-this2.C
@@ -0,0 +1,8 @@
+// PR c++/56701
+// { dg-do compile { target c++11 } }
+
+struct A
+{
+  void f(){ A*&& a = &*this; }
+};
+int main(){}

Reply via email to