From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23209 invoked by alias); 7 Jun 2011 12:03:41 -0000 Received: (qmail 23194 invoked by uid 22791); 7 Jun 2011 12:03:40 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,RFC_ABUSE_POST X-Spam-Check-By: sourceware.org Received: from mail-wy0-f175.google.com (HELO mail-wy0-f175.google.com) (74.125.82.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 07 Jun 2011 12:03:26 +0000 Received: by wye20 with SMTP id 20so4143142wye.20 for ; Tue, 07 Jun 2011 05:03:25 -0700 (PDT) MIME-Version: 1.0 Received: by 10.227.62.207 with SMTP id y15mr3792305wbh.86.1307448205629; Tue, 07 Jun 2011 05:03:25 -0700 (PDT) Received: by 10.227.37.152 with HTTP; Tue, 7 Jun 2011 05:03:25 -0700 (PDT) In-Reply-To: <20110607102717.GZ17079@tyan-ft48-01.lab.bos.redhat.com> References: <4DEDB98F.6010508@redhat.com> <20110607102717.GZ17079@tyan-ft48-01.lab.bos.redhat.com> Date: Tue, 07 Jun 2011 12:03:00 -0000 Message-ID: Subject: Re: RFA (fold): PATCH for c++/49290 (folding *(T*)(ar+10)) From: Richard Guenther To: Jakub Jelinek Cc: Jason Merrill , Richard Guenther , gcc-patches List Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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/msg00505.txt.bz2 On Tue, Jun 7, 2011 at 12:27 PM, Jakub Jelinek wrote: > 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 ARR= AY_REF >> > because T !=3D unsigned. =A0Even 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. =A0Is it= really >> > necessary that the type of the ARRAY_REF match exactly the element typ= e of >> > the array? >> >> I _think_ that you can unconditionally change the code to do >> >> =A0 TYPE_MAIN_VARIANT (t1) =3D=3D TYPE_MAIN_VARIANT (t2) >> =A0 && TYPE_QUALS (t1) =3D=3D TYPE_QUALS (t2) >> >> now, I'm not sure if for the testcase T and unsigned differ in qualifier= s. > > 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. I'm not sure that's a good idea if the caller wants an lvalue. Richard. > =A0 =A0 =A0 =A0Jakub >