From: Jason Merrill Date: Fri, 30 Jun 2006 21:25:21 +0000 (-0400) Subject: re PR c++/26577 (ICE in cp_expr_size with volatile and non POD) X-Git-Tag: releases/gcc-4.0.4~571 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c166b68978148b4c4fc2d89b068756e4494cc797;p=thirdparty%2Fgcc.git re PR c++/26577 (ICE in cp_expr_size with volatile and non POD) PR c++/26577 * call.c (build_new_method_call): Force evaluation of the instance pointer, not the object. From-SVN: r115107 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 402f39a063f9..1afdbce92355 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +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. + PR c++/18698 * decl2.c (grokfield): Only try to treat the decl as an access declaration if the scope is a class. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 468fd23a31ad..aaee1fb36c9e 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -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 index 000000000000..9080ed5dc659 --- /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(); +}