From 6130a79d9af44eeefa6022bb7a954ded2c28d105 Mon Sep 17 00:00:00 2001 From: jason Date: Fri, 30 Jun 2006 20:48:42 +0000 Subject: [PATCH] PR c++/26577 * call.c (build_new_method_call): Force evaluation of the instance pointer, not the object. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@115105 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/call.c | 4 ++-- gcc/testsuite/g++.dg/init/volatile1.C | 16 ++++++++++++++++ 3 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/init/volatile1.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 18551fb..29888c7 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2006-06-30 Jason Merrill + + PR c++/26577 + * call.c (build_new_method_call): Force evaluation of the + instance pointer, not the object. + 2006-06-30 Kazu Hirata * decl2.c: Fix a comment typo. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 970fce7..ea89cdf 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -5501,9 +5501,9 @@ build_new_method_call (tree instance, tree fns, tree args, none-the-less evaluated. */ if (TREE_CODE (TREE_TYPE (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 index 0000000..9080ed5 --- /dev/null +++ b/gcc/testsuite/g++.dg/init/volatile1.C @@ -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(); +} -- 2.7.4