From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 81837 invoked by alias); 20 Mar 2015 14:53:56 -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 81764 invoked by uid 89); 20 Mar 2015 14:53:55 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.6 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; Fri, 20 Mar 2015 14:53:54 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t2KErrOg016191 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 20 Mar 2015 10:53:53 -0400 Received: from [10.10.116.33] ([10.10.116.33]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t2KErqt0013821; Fri, 20 Mar 2015 10:53:52 -0400 Message-ID: <550C347E.2070801@redhat.com> Date: Fri, 20 Mar 2015 14:53:00 -0000 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: Jakub Jelinek , Richard Biener CC: Marek Polacek , GCC Patches Subject: Re: C++ PATCH for c++/65398 (valid constexpr rejected) References: <20150313144052.GU26802@redhat.com> <20150319180536.GA1746@tucnak.redhat.com> In-Reply-To: <20150319180536.GA1746@tucnak.redhat.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2015-03/txt/msg01080.txt.bz2 On 03/19/2015 02:05 PM, Jakub Jelinek wrote: > 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. I don't see an out-of-bound access in this example; taking the address of one-past-the-end is OK as long as you don't try to access through it. > Unfortunately we reject even that (regardless the patch), and yeah, it's > because of how POINTER_PLUS_EXPR uses sizetype as a type of the second operand. This seems like something to fix in this patch. > + tree t = fold_convert_loc (loc, TREE_TYPE (op01), > + TREE_OPERAND (op00, 1)); > + t = size_binop_loc (loc, PLUS_EXPR, op01, t); This seems to be assuming that the elements are size 1. Jason