From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11393 invoked by alias); 3 Apr 2006 17:22:38 -0000 Received: (qmail 11362 invoked by alias); 3 Apr 2006 17:22:35 -0000 Date: Mon, 03 Apr 2006 17:22:00 -0000 Message-ID: <20060403172235.11361.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug tree-optimization/26763] [4.1 Regression] wrong final value of induction variable calculated In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "rakdver at atrey dot karlin dot mff dot cuni dot cz" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2006-04/txt/msg00196.txt.bz2 List-Id: ------- Comment #10 from rakdver at atrey dot karlin dot mff dot cuni dot cz 2006-04-03 17:22 ------- Subject: Re: [4.1 Regression] wrong final value of induction variable calculated > > (In reply to comment #6) > > > I believe c-common.c:pointer_int_sum is wrong in relying on pointer overflow > > > during conversion of the integer offset to an unsigned pointer. I'm sending > > > a patch that fixes this for comments. > > > > The patch seems a bit too conservative to me; perhaps just always comparing the > > offsets as signed could work? > > I'm not a language lawyer here - and as this is the second (or third) > patch to this folding to correct problems I'd rather be safe than sorry > this time. I'm sure jsm can construct a testcase where comparing offsets > as signed leads to wrong code. Maybe > > char *memory = 0; > > int foo(void) > { > return memory + 0x80000000 < memory; > } > > int main() > { > if (foo()) > abort (); > } > > i.e. have a mapping >2Gb on a 32bit machine. A corner case, but valid I > guess. no -- the result in this example is undefined. The comparisons are only defined for pointers in the same object. I guess nothing really prevents having an object whose size is more than half of the address space, though. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26763