]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/26577 (ICE in cp_expr_size with volatile and non POD)
authorJason Merrill <jason@redhat.com>
Fri, 30 Jun 2006 21:25:21 +0000 (17:25 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 30 Jun 2006 21:25:21 +0000 (17:25 -0400)
        PR c++/26577
        * call.c (build_new_method_call): Force evaluation of the
        instance pointer, not the object.

From-SVN: r115107

gcc/cp/ChangeLog
gcc/cp/call.c
gcc/testsuite/g++.dg/init/volatile1.C [new file with mode: 0644]

index 402f39a063f90804a488c9e02b11261f9c8d6e1f..1afdbce92355745e33673854d9521359f29aac87 100644 (file)
@@ -1,5 +1,9 @@
 2006-06-30  Jason Merrill  <jason@redhat.com>
 
+       PR c++/26577
+       * call.c (build_new_method_call): Force evaluation of the 
+       instance pointer, not the object.
+
        PR c++/18698
        * decl2.c (grokfield): Only try to treat the decl as an access 
        declaration if the scope is a class.
index 468fd23a31adfe5e0155a1a121fbbdd947a7b7b3..aaee1fb36c9e636274b116845f5f6a3365be0cff 100644 (file)
@@ -5434,9 +5434,9 @@ build_new_method_call (tree instance, tree fns, tree args,
                 none-the-less evaluated.  */
              if (TREE_CODE (TREE_TYPE (cand->fn)) != METHOD_TYPE
                  && !is_dummy_object (instance_ptr) 
-                 && TREE_SIDE_EFFECTS (instance))
+                 && TREE_SIDE_EFFECTS (instance_ptr))
                call = build2 (COMPOUND_EXPR, TREE_TYPE (call), 
-                              instance, call);
+                              instance_ptr, call);
            }
        }
     }
diff --git a/gcc/testsuite/g++.dg/init/volatile1.C b/gcc/testsuite/g++.dg/init/volatile1.C
new file mode 100644 (file)
index 0000000..9080ed5
--- /dev/null
@@ -0,0 +1,16 @@
+// PR c++/26577
+// The call to bar() was causing an inappropriate dereference of *this,
+// which led to an abort in cp_expr_size.
+
+struct A
+{
+  A(const A&);
+  A& operator=(const A&);
+  static void bar();
+  void baz() volatile;
+};
+
+void A::baz() volatile
+{
+  bar();
+}