autoconf-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: changing "configure" to default to "gcc -g -O2 -fwrapv ..."


From: Richard Kenner
Subject: Re: changing "configure" to default to "gcc -g -O2 -fwrapv ..."
Date: Sun, 31 Dec 2006 08:25:23 EST

> > > I suppose there is
> > > 
> > >       *hv = (HOST_WIDE_INT) -(unsigned HOST_WIDE_INT) h1;
> > > 
> > > to make it safe.
> > 
> > Can't that conversion overflow?
> 
> Not on a two's complement machine, 

Then I'm confused about C's arithmetic rules.  Suppose h1 is 1. It's cast
to unsigned, so stays as 1.  Now we do unary minus in unsigned.  That's ~0
because it's done mod 2**32, but interpreted as a POSITIVE number.  Now,
that positive number overflows when converted to signed (the intent is for
that overflow make it negative).  Am I missing something (quite likely!)?




reply via email to

[Prev in Thread] Current Thread [Next in Thread]