From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9270 invoked by alias); 7 Jun 2011 10:27:36 -0000 Received: (qmail 9145 invoked by uid 22791); 7 Jun 2011 10:27:36 -0000 X-SWARE-Spam-Status: No, hits=-6.5 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 07 Jun 2011 10:27:20 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p57ARKLR010805 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 7 Jun 2011 06:27:20 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [10.16.42.4]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p57ARIMk008768 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 7 Jun 2011 06:27:19 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (localhost.localdomain [127.0.0.1]) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4) with ESMTP id p57ARIsY028021; Tue, 7 Jun 2011 12:27:18 +0200 Received: (from jakub@localhost) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4/Submit) id p57ARHjp028019; Tue, 7 Jun 2011 12:27:17 +0200 Date: Tue, 07 Jun 2011 10:27:00 -0000 From: Jakub Jelinek To: Richard Guenther Cc: Jason Merrill , Richard Guenther , gcc-patches List Subject: Re: RFA (fold): PATCH for c++/49290 (folding *(T*)(ar+10)) Message-ID: <20110607102717.GZ17079@tyan-ft48-01.lab.bos.redhat.com> Reply-To: Jakub Jelinek References: <4DEDB98F.6010508@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes 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 X-SW-Source: 2011-06/txt/msg00496.txt.bz2 On Tue, Jun 07, 2011 at 12:19:59PM +0200, Richard Guenther wrote: > On Tue, Jun 7, 2011 at 7:39 AM, Jason Merrill wrote: > > In the testcase, fold_indirect_ref_1 won't fold *(T*)(s1+10) to an ARRAY_REF > > because T != unsigned.  Even if it were just a typedef to unsigned, that > > isn't close enough, but in this case it's a typedef to const unsigned. > > > > I'm not sure what the type coherence rules are for ARRAY_REF.  Is it really > > necessary that the type of the ARRAY_REF match exactly the element type of > > the array? > > I _think_ that you can unconditionally change the code to do > > TYPE_MAIN_VARIANT (t1) == TYPE_MAIN_VARIANT (t2) > && TYPE_QUALS (t1) == TYPE_QUALS (t2) > > now, I'm not sure if for the testcase T and unsigned differ in qualifiers. I guess folding into array_ref that way is fine, but you should in the end fold_convert_loc it to the expected type, while the middle-end has the notion of useless type conversions, fold-const.c is also used by FEs and I think it is expected to have the types exactly matching. So (T)s1[10] instead of s1[10] in this case. Jakub