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
problems?
I suppose there is
*hv = (HOST_WIDE_INT) -(unsigned HOST_WIDE_INT) h1;
to make it safe.