From: Jakub Jelinek Date: Fri, 19 Nov 2010 23:50:21 +0000 (+0100) Subject: re PR c++/46526 (VTable Problem?) X-Git-Tag: releases/gcc-4.6.0~2455 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e26ab5ecd292a31bbae2108502ff532db2d6f245;p=thirdparty%2Fgcc.git re PR c++/46526 (VTable Problem?) PR c++/46526 * semantics.c (cxx_eval_call_expression): Unshare the result. * g++.dg/cpp0x/constexpr-base3.C: New test. From-SVN: r166967 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index b192ed150db5..e3d97d22d559 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2010-11-20 Jakub Jelinek + + PR c++/46526 + * semantics.c (cxx_eval_call_expression): Unshare the result. + 2010-11-19 Nicola Pero * parser.c (cp_parser_objc_protocol_declaration): Pass attributes diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 38e03f6060de..9b565daed840 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -6042,7 +6042,7 @@ cxx_eval_call_expression (const constexpr_call *old_call, tree t, } pop_cx_call_context (); - return result; + return unshare_expr (result); } /* FIXME speed this up, it's taking 16% of compile time on sieve testcase. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 38a694cf3d54..1a543089601a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2010-11-20 Jakub Jelinek + PR c++/46526 + * g++.dg/cpp0x/constexpr-base3.C: New test. + PR tree-optimization/45830 * gcc.target/i386/pr45830.c: New test. * gcc.c-torture/execute/pr45830.c: New test. diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-base3.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-base3.C new file mode 100644 index 000000000000..cffe9ea240c7 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-base3.C @@ -0,0 +1,27 @@ +// PR c++/46526 +// { dg-do run } +// { dg-options "-std=c++0x" } + +struct Base +{ + virtual int getid () = 0; +}; + +struct A : public Base +{ + virtual int getid () { return 1; } +}; + +struct B : public Base +{ + virtual int getid () { throw "here"; } +}; + +int +main () +{ + A a; + B b; + Base& ar = a; + ar.getid (); +}