This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix PR c++/70121 (premature folding of const var that was implicitly captured)
- From: Patrick Palka <patrick at parcs dot ath dot cx>
- To: Jason Merrill <jason at redhat dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 18 Mar 2016 11:31:11 -0400
- Subject: Re: [PATCH] Fix PR c++/70121 (premature folding of const var that was implicitly captured)
- Authentication-results: sourceware.org; auth=none
- References: <1457650689-16404-1-git-send-email-patrick at parcs dot ath dot cx> <56EC1B61 dot 80901 at redhat dot com>
On Fri, Mar 18, 2016 at 11:14 AM, Jason Merrill <jason@redhat.com> wrote:
> On 03/10/2016 05:58 PM, Patrick Palka wrote:
>>
>> This patch reverses the behavior of process_outer_var_ref, so that we
>> always implicitly capture a const variable if it's capturable, instead
>> of always trying to first fold it to a constant. This behavior however
>> is wrong too, and introduces a different but perhaps less important
>> regression: if we implicitly capture by value a const object that is not
>> actually odr-used within the body of the lambda, we may introduce a
>> redundant call to its copy/move constructor, see pr70121-2.C.
>
>
> In general I'm disinclined to trade one bug for another, and I'm skeptical
> that the different regression is less important; I imagine that most uses of
> const variables will be for their constant value rather than their address.
Okay, I may try to implement a complete fix for GCC 7 then.