From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28482 invoked by alias); 23 Mar 2016 19:19:29 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 28472 invoked by uid 89); 23 Mar 2016 19:19:28 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.9 required=5.0 tests=BAYES_00,KAM_LAZY_DOMAIN_SECURITY,SPF_HELO_PASS,T_RP_MATCHES_RCVD autolearn=no version=3.3.2 spammy=folded, risk X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Wed, 23 Mar 2016 19:19:27 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 1E57D7AE95; Wed, 23 Mar 2016 19:19:26 +0000 (UTC) Received: from [10.3.113.58] (ovpn-113-58.phx2.redhat.com [10.3.113.58]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u2NJJOnD003947; Wed, 23 Mar 2016 15:19:24 -0400 Subject: Re: [PATCH] c++/67376 Comparison with pointer to past-the-end, of array fails inside constant expression To: Martin Sebor , Jeff Law , Gcc Patch List References: <56E72C33.8000301@gmail.com> <56E9B9C3.5000908@redhat.com> <56EB1ECA.90800@gmail.com> <56EC3500.4030701@redhat.com> <56F03567.8040306@redhat.com> <56F07137.1050400@redhat.com> <56F19456.3030900@redhat.com> <56F1A494.1060407@gmail.com> Cc: Marek Polacek , Jakub Jelinek From: Jason Merrill Message-ID: <56F2EC3C.5000606@redhat.com> Date: Wed, 23 Mar 2016 20:41:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: <56F1A494.1060407@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2016-03/txt/msg01355.txt.bz2 On 03/22/2016 04:01 PM, Martin Sebor wrote: > On 03/22/2016 12:52 PM, Jason Merrill wrote: >> On 03/21/2016 06:09 PM, Jeff Law wrote: >>> On 03/21/2016 11:54 AM, Jason Merrill wrote: >>>>>> Both b0 and b1 are invalid and should be diagnosed, but only b1 >>>>>> is. b1 isn't because because by the time we see its initializer >>>>>> in constexpr.c it's been transformed into the equivalent of "b1 >>>>>> = (int*)ps" (though we don't see the cast which would also make >>>>>> it invalid). >>>>>> >>>>>> But if we can avoid these early simplifying transformations and >>>>>> retain a more faithful representation of the original source then >>>>>> doing the checking later will likely be simpler and result in >>>>>> detecting more problems with greater consistency and less effort. >>>>> Do we know where the folding is happening for this case and is it >>>>> something we can reasonably defer? ie, is this just a case we >>>>> missed >>>>> as part of the deferred folding work and hence should have its own >>>>> distinct BZ to track? >>>> >>>> Yes, why is it already folded? >> >>> Let's pull that out into a separate BZ and tackle it for gcc-7. >> >> I need to understand the issue before I agree to defer it. >> >> It turns out that the problem is with how cp_build_binary_op calls >> cp_pointer_int_sum and thus the c-common pointer_int_sum, which folds. >> >> The POINTER_PLUS_EXPRs thus created have been a source of many issues >> with constexpr evaluation, since it's impossible to reconstruct the >> original expression, especially because POINTER_PLUS_EXPR uses an >> unsigned second operand. Deferring lowering to POINTER_PLUS_EXPR would >> help a lot. But it would indeed be a significant risk at this point. >> >> I think let's defer the fix for c++/60760 (i.e. the nullptr_p bits) >> until stage 1, when it can be combined with the POINTER_PLUS_EXPR fix, >> and put the rest of this patch in now. > > I can split up the patch into two and post the subset without > the fix for c++/60760, though I don't expect to be done with > it after I get back (next week). > > I'd like to understand your concern with the fix for c++/60760. > Is it that it's incomplete (doesn't reject taking the address > of the first member of a struct, as in &null->first_member), > or are you worried that the changes may not be stable enough? More the latter; it seems like significant new code and doesn't fix a regression. Jason