From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21131 invoked by alias); 5 Aug 2005 17:58:00 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 21113 invoked by uid 22791); 5 Aug 2005 17:57:57 -0000 Received: from mx1.redhat.com (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Fri, 05 Aug 2005 17:57:57 +0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.12.11/8.12.11) with ESMTP id j75Hvrpb031529; Fri, 5 Aug 2005 13:57:53 -0400 Received: from pobox.corp.redhat.com (pobox.corp.redhat.com [172.16.52.156]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id j75HvrV17600; Fri, 5 Aug 2005 13:57:53 -0400 Received: from vpn83-164.boston.redhat.com (vpn83-164.boston.redhat.com [172.16.83.164]) by pobox.corp.redhat.com (8.12.8/8.12.8) with ESMTP id j75HvlED006662; Fri, 5 Aug 2005 13:57:47 -0400 Subject: Re: PR 23046. Folding predicates involving TYPE_MAX_VALUE/TYPE_MIN_VALUE From: Jeffrey A Law Reply-To: law@redhat.com To: Diego Novillo Cc: Roger Sayle , gcc@gcc.gnu.org In-Reply-To: <20050805135953.GA23609@topo.toronto.redhat.com> References: <20050805135953.GA23609@topo.toronto.redhat.com> Content-Type: text/plain Date: Fri, 05 Aug 2005 17:58:00 -0000 Message-Id: <1123264666.8684.94.camel@localhost.localdomain> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-SW-Source: 2005-08/txt/msg00179.txt.bz2 On Fri, 2005-08-05 at 09:59 -0400, Diego Novillo wrote: > In PR 23046 we ICE inside tree-vrp.c because fold() does not > realize that for > > enum enumtype { ENUM1, ENUM2 } x; > > the predicate 'if (x > 1)' is always false. This causes VRP to > create the impossible range [2, 1] for that predicate. > > While it would be trivial for VRP to paper over this problem, the > real fix should be in fold(). I looked at the logic that detects > these cases and it is fairly convoluted (fold-const.c:9174). > > I'm wondering why doesn't fold() just use TYPE_MAX_VALUE/TYPE_MIN_VALUE > if they're available? IIRC the C standard does not guarantee that an object stay within the bounds of its enumerated type. You'll have to do some digging in the relevant standards. jeff