[Top][All Lists]

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

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

From: Joe Buck
Subject: Re: changing "configure" to default to "gcc -g -O2 -fwrapv ..."
Date: Sat, 30 Dec 2006 17:34:01 -0800
User-agent: Mutt/1.4.1i

On Sat, Dec 30, 2006 at 04:13:08PM -0800, Paul Eggert wrote:
> I am.  I just now looked and found another example.
> gcc-4.3-20061223/gcc/fold-const.c's neg_double function
> contains this line:
>       *hv = - h1;
> This one is a bit less obvious because it doesn't have a
> "Danger Will Robinson!" comment next to it, but h1 is a
> signed integer and it's easy to arrange for h1 to have its
> minimal value, so that "- h1" overflows.

This code would blow up if an integer overflow caused a trap.
I wonder if -ftrapv could be used to catch these kinds of

I suppose there is

      *hv = (HOST_WIDE_INT) -(unsigned HOST_WIDE_INT) h1;

to make it safe.

reply via email to

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