This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
C++ PATCH to build_new_method_call for c++/26577
- From: Jason Merrill <jason at redhat dot com>
- To: "gcc-patches >> GCC Patches" <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 30 Jun 2006 16:45:13 -0400
- Subject: C++ PATCH to build_new_method_call for c++/26577
In this PR, a call to a static member function from within a volatile
non-static member function was reformed to
*this, A::bar();
causing the backend to try to copy *this to a temporary, which lead to
an abort in cp_expr_size. The bug is in the translation above: a call
to a static member function should not imply a dereference of 'this'.
Fixed by forcing evaluation of the object pointer, not the object itself.
Tested x86_64-pc-linux-gnu, applied to trunk.
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.
Index: cp/call.c
===================================================================
*** cp/call.c (revision 115085)
--- cp/call.c (working copy)
*************** build_new_method_call (tree instance, tr
*** 5501,5509 ****
none-the-less evaluated. */
if (TREE_CODE (TREE_TYPE (fn)) != METHOD_TYPE
&& !is_dummy_object (instance_ptr)
! && TREE_SIDE_EFFECTS (instance))
call = build2 (COMPOUND_EXPR, TREE_TYPE (call),
! instance, call);
}
}
}
--- 5501,5509 ----
none-the-less evaluated. */
if (TREE_CODE (TREE_TYPE (fn)) != METHOD_TYPE
&& !is_dummy_object (instance_ptr)
! && TREE_SIDE_EFFECTS (instance_ptr))
call = build2 (COMPOUND_EXPR, TREE_TYPE (call),
! instance_ptr, call);
}
}
}
Index: testsuite/g++.dg/init/volatile1.C
===================================================================
*** testsuite/g++.dg/init/volatile1.C (revision 0)
--- testsuite/g++.dg/init/volatile1.C (revision 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();
+ }