Re: [Ping] [Patch C++] RFC Fix PR57958
Hello, Here is another version of fix. This time, I added complete_type_or_else call just before aggregate_value_p. Bootstraped and tested on x86_64-pc-linux-gnu with no new regressions. Ok to apply to trunk? Thanks, Dinar. On Mon, Apr 7, 2014 at 11:47 PM, Jason Merrill ja...@redhat.com wrote: On 04/07/2014 03:46 PM, Jason Merrill wrote: I guess we need to call complete_type before aggregate_value_p. complete_type_or_else, actually. Jason 2014-04-18 Dinar Temirbulatov dtemirbula...@gmail.com PR c++/57958 * semantics.c (apply_deduced_return_type): Complete non-void type before estimating whether the type is aggregate. fix.patch Description: Binary data
Re: [Ping] [Patch C++] RFC Fix PR57958
I found typo in the testcase header, fixed. Ok to apply to trunk? thanks, Dinar. On Fri, Apr 18, 2014 at 1:13 PM, Dinar Temirbulatov dtemirbula...@gmail.com wrote: Hello, Here is another version of fix. This time, I added complete_type_or_else call just before aggregate_value_p. Bootstraped and tested on x86_64-pc-linux-gnu with no new regressions. Ok to apply to trunk? Thanks, Dinar. On Mon, Apr 7, 2014 at 11:47 PM, Jason Merrill ja...@redhat.com wrote: On 04/07/2014 03:46 PM, Jason Merrill wrote: I guess we need to call complete_type before aggregate_value_p. complete_type_or_else, actually. Jason 2014-04-18 Dinar Temirbulatov dtemirbula...@gmail.com PR c++/57958 * semantics.c (apply_deduced_return_type): Complete non-void type before estimating whether the type is aggregate. fix.patch Description: Binary data
Re: [Ping] [Patch C++] RFC Fix PR57958
On 04/18/2014 08:53 AM, Dinar Temirbulatov wrote: + if (TREE_CODE (TREE_TYPE(result)) != VOID_TYPE) Space after TREE_TYPE. OK with that change. Jason
Re: [Ping] [Patch C++] RFC Fix PR57958
Hi, On 18 aprile 2014 17:20:40 CEST, Jason Merrill ja...@redhat.com wrote: On 04/18/2014 08:53 AM, Dinar Temirbulatov wrote: + if (TREE_CODE (TREE_TYPE(result)) != VOID_TYPE) Space after TREE_TYPE. OK with that change. I'm traveling and I can't really check, but I seem to remember that we do have a VOID_TYPE_P. Paolo
Re: [Ping] [Patch C++] RFC Fix PR57958
On 04/18/2014 11:39 AM, Paolo Carlini wrote: I'm traveling and I can't really check, but I seem to remember that we do have a VOID_TYPE_P. True, I suppose that would be preferable. Jason
[Ping] [Patch C++] RFC Fix PR57958
Hi, I revised the patch from http://gcc.gnu.org/ml/gcc-patches/2014-04/msg00083.html. This change fixes PR57958 (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57958) For this code: auto fn = [] (const FooData x) { return (x); }; { FooData a; fn(a); } Current version of trunk generates following gimple: main(int, char**)::lambda(const FooData) (const struct __lambda0 * const __closure, const struct Foo x) { struct Foo D.2089; FooData::Foo (D.2089, x); try { return retval; } finally { FooData::~Foo (D.2089); D.2089 = {CLOBBER}; } } And after fix applied gimple product looks like this: main(int, char**)::lambda(const FooData) (const struct __lambda0 * const __closure, const struct Foo x) { FooData::Foo (retval, x); return retval; } looking at the code that I think caused the issue: cp/typeck.c:8600 /* We can't initialize a register from a AGGR_INIT_EXPR. */ else if (! cfun-returns_struct TREE_CODE (retval) == TARGET_EXPR TREE_CODE (TREE_OPERAND (retval, 1)) == AGGR_INIT_EXPR) retval = build2 (COMPOUND_EXPR, TREE_TYPE (retval), retval, TREE_OPERAND (retval, 0)); It is not clear to me the propose of constructing COMPOUND_EXPR here, comment says: We can't initialize a register from a AGGR_INIT_EXPR., but how on the front-end side we could determine what is going to end up in a register and what is not? The code looks like a hack for some middle-end issue awhile back? I hoped to trigger any code generation problem by removing the code and testing regression testsuite on x86_64-pc-linux-gnu, but no regression have occured. Attached patch was tested on x86_64-pc-linux-gnu with no new regressions. Ok to apply to trunk? Thanks in advance, Dinar. PR57958.patch Description: Binary data
Re: [Ping] [Patch C++] RFC Fix PR57958
On 04/07/2014 12:56 PM, Dinar Temirbulatov wrote: /* We can't initialize a register from a AGGR_INIT_EXPR. */ else if (! cfun-returns_struct TREE_CODE (retval) == TARGET_EXPR TREE_CODE (TREE_OPERAND (retval, 1)) == AGGR_INIT_EXPR) retval = build2 (COMPOUND_EXPR, TREE_TYPE (retval), retval, TREE_OPERAND (retval, 0)); That code is extremely ancient. I agree that it seems kind of useless, but the fact that we're hitting it indicates a bug: cfun-returns_struct should have been set by apply_deduced_return_type. I guess we need to call complete_type before aggregate_value_p. Let's fix that now, and then remove this chunk of code after 4.9 branches. +++ b/gcc/testsuite/g++.dg/cpp1y/pr57958.C The cpp1y directory is for C++14 tests; C++11 tests should go in cpp0x. Perhaps we should rename the directories. :) +// { dg-options -std=c++11 } +// { dg-do run } Please use { dg-do run { target c++11 } } rather than specify -std in dg-options. Jason
Re: [Ping] [Patch C++] RFC Fix PR57958
On 04/07/2014 03:46 PM, Jason Merrill wrote: I guess we need to call complete_type before aggregate_value_p. complete_type_or_else, actually. Jason