From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5386 invoked by alias); 7 Jun 2011 10:20:17 -0000 Received: (qmail 5373 invoked by uid 22791); 7 Jun 2011 10:20:16 -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-ww0-f51.google.com (HELO mail-ww0-f51.google.com) (74.125.82.51) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 07 Jun 2011 10:20:00 +0000 Received: by wwf26 with SMTP id 26so4337751wwf.8 for ; Tue, 07 Jun 2011 03:19:59 -0700 (PDT) MIME-Version: 1.0 Received: by 10.227.209.146 with SMTP id gg18mr6162320wbb.71.1307441999150; Tue, 07 Jun 2011 03:19:59 -0700 (PDT) Received: by 10.227.37.152 with HTTP; Tue, 7 Jun 2011 03:19:59 -0700 (PDT) In-Reply-To: <4DEDB98F.6010508@redhat.com> References: <4DEDB98F.6010508@redhat.com> Date: Tue, 07 Jun 2011 10:20:00 -0000 Message-ID: Subject: Re: RFA (fold): PATCH for c++/49290 (folding *(T*)(ar+10)) From: Richard Guenther To: Jason Merrill Cc: 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/msg00494.txt.bz2 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 !=3D unsigned. =A0Even if it were just a typedef to unsigned, t= hat > 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 re= ally > 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) =3D=3D TYPE_MAIN_VARIANT (t2) && TYPE_QUALS (t1) =3D=3D TYPE_QUALS (t2) now, I'm not sure if for the testcase T and unsigned differ in qualifiers. Do they? > In any case, constexpr expansion can be more flexible about type coherence > because it is just trying to get a constant value; if that doesn't work o= ut, > we throw it away and fall back on the original expression. =A0We already > handle some cases in cxx_eval_indirect_ref that aren't appropriate for > fold_indirect_ref_1, but this testcase demonstrates that we also want to > adjust the cases that are handled by that function. > > So my options would seem to be either duplicating the whole of > fold_indirect_ref_1, which tempts undesirable divergence, or adding a flag > to that function to enable the more permissive type checking that the > constexpr code wants. > > Does this seem like a reasonable thing to do? So, I'd rather go the above way if it works for this case. Thanks, Richard. >