From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 125522 invoked by alias); 19 Mar 2015 18:05:44 -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 125501 invoked by uid 89); 19 Mar 2015 18:05:44 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 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; Thu, 19 Mar 2015 18:05:43 +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 (8.14.4/8.14.4) with ESMTP id t2JI5fPZ024472 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 19 Mar 2015 14:05:41 -0400 Received: from tucnak.zalov.cz (ovpn-116-63.ams2.redhat.com [10.36.116.63]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t2JI5ddl004647 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=NO); Thu, 19 Mar 2015 14:05:40 -0400 Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.14.9/8.14.9) with ESMTP id t2JI5bIM005202; Thu, 19 Mar 2015 19:05:38 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.14.9/8.14.9/Submit) id t2JI5anR002742; Thu, 19 Mar 2015 19:05:36 +0100 Date: Thu, 19 Mar 2015 18:05:00 -0000 From: Jakub Jelinek To: Richard Biener , Jason Merrill Cc: Marek Polacek , GCC Patches Subject: Re: C++ PATCH for c++/65398 (valid constexpr rejected) Message-ID: <20150319180536.GA1746@tucnak.redhat.com> Reply-To: Jakub Jelinek References: <20150313144052.GU26802@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes X-SW-Source: 2015-03/txt/msg01025.txt.bz2 On Wed, Mar 18, 2015 at 11:08:15AM +0100, Richard Biener wrote: > On Fri, Mar 13, 2015 at 3:40 PM, Marek Polacek wrote: > > We started to reject this (IMHO valid) testcase with r214941 that did away with > > try_move_mult_to_index -- meaning that we are no longer able to fold *(&s[0] + 1) > > into s[1], while we are able to fold *(s + 1) into s[1]. > > > > I suppose cxx_fold_indirect_ref ought to be able to handle both cases, so I added > > some code to that effect, it should handle now at least the simple cases... > > Or should that be handled in the middle end? > > It's "correct" for constexpr folding but not correct to hand s[1] down to > the middle-end IL (both cases). Well, in the particular case with > in-array-bound constant and a non-pointer base it's good enough at > least. I believe cxx_fold_indirect_ref result is not passed through to the middle-end, unless it can be folded into a constant. Though, a question is if we do (or, if we don't and should) reject say constexpr char s[] = "abc"; constexpr int j = 4; constexpr char c = *(&s[j] - 2); because there was out of bound access in there. Jakub