PATCH: Bad signed int to long long conversion
vincent at vinc17.net
Thu Dec 1 14:20:58 CET 2011
On 2011-12-01 14:12:41 +0100, Vincent Lefevre wrote:
> On 2011-12-01 13:13:05 +0100, Torbjorn Granlund wrote:
> > The GCC bug report involves two operand sizes, and is indeed invalid.
> AFAIK, the VRP logic is not based on these two operand sizes.
> What matters here is that the subtraction (where only one type
> is involved) overflows and GCC assumes that this cannot occur
> in a correct program.
Here's a testcase showing that even with a single type, one gets
problems with -LONG_MIN:
int foo (long i)
long j = i < 0 ? -i : i;
return j >= 0;
int main (void)
volatile long i = LONG_MIN;
printf ("%d\n", foo (i));
ypig:~> gcc tst.c -o tst; ./tst
ypig:~> gcc -O2 tst.c -o tst; ./tst
Vincent Lefèvre <vincent at vinc17.net> - Web: <http://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / Arénaire project (LIP, ENS-Lyon)
More information about the gmp-bugs