From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6906 invoked by alias); 21 Mar 2016 17:54:52 -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 6893 invoked by uid 89); 21 Mar 2016 17:54:51 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=consistency, Hx-languages-length:1537, difficulty 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; Mon, 21 Mar 2016 17:54:50 +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 1162D3D7; Mon, 21 Mar 2016 17:54:49 +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 u2LHslJw016391; Mon, 21 Mar 2016 13:54:48 -0400 Subject: Re: [PATCH] c++/67376 Comparison with pointer to past-the-end, of array fails inside constant expression To: Jeff Law , Martin Sebor , Gcc Patch List References: <56E72C33.8000301@gmail.com> <56E9B9C3.5000908@redhat.com> <56EB1ECA.90800@gmail.com> <56EC3500.4030701@redhat.com> Cc: Marek Polacek , Jakub Jelinek From: Jason Merrill Message-ID: <56F03567.8040306@redhat.com> Date: Mon, 21 Mar 2016 17:55: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: <56EC3500.4030701@redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2016-03/txt/msg01195.txt.bz2 On 03/18/2016 01:04 PM, Jeff Law wrote: > On 03/17/2016 03:16 PM, Martin Sebor wrote: >> The difficulty I've run into with detecting these problems in later >> phases is that some invalid expressions have already been simplified >> by the front end. The example that applies here (even though this >> is still the front end) is this: > Yea. I was hoping that the delayed folding work would be helping in > getting a more faithful representation out of the front-ends. It should. >> constexpr int* p = 0; >> constexpr bool b0 = &p[0] == 0; // accepted >> constexpr bool b1 = &p[1] == 0; // rejected >> >> 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? Jason