re PR other/15526 (-ftrapv aborts on 0 * (-1))

PR other/15526
	* libgcc2.c (__mulvsi3): Fix overflow test.
	* gcc.dg/ftrapv-1.c: New test case.

From-SVN: r82042
This commit is contained in:
Falk Hueffner 2004-05-20 01:43:20 +02:00 committed by Falk Hueffner
parent dc44e18a62
commit d3a7ef9aac
4 changed files with 36 additions and 3 deletions

View file

@ -1,3 +1,8 @@
2004-05-20 Falk Hueffner <falk@debian.org>
PR other/15526
* libgcc2.c (__mulvsi3): Fix overflow test.
2004-05-19 Andrew Pinski <pinskia@physics.uc.edu>
PR c/14171

View file

@ -130,9 +130,7 @@ __mulvsi3 (Wtype a, Wtype b)
{
const DWtype w = (DWtype) a * (DWtype) b;
if (((a >= 0) == (b >= 0))
? (UDWtype) w > (UDWtype) (((DWtype) 1 << (WORD_SIZE - 1)) - 1)
: (UDWtype) w < (UDWtype) ((DWtype) -1 << (WORD_SIZE - 1)))
if ((Wtype) (w >> WORD_SIZE) != (Wtype) w >> (WORD_SIZE - 1))
abort ();
return w;

View file

@ -1,3 +1,8 @@
2004-05-20 Falk Hueffner <falk@debian.org>
PR other/15526
* gcc.dg/ftrapv-1.c: New test case.
2004-05-18 Feng Wang <fengwang@nudt.edu.cn>
* gfortran.fortran-torture/execute/power.f90: Test constant integers.

View file

@ -0,0 +1,25 @@
/* Copyright (C) 2004 Free Software Foundation.
PR other/15526
Verify correct overflow checking with -ftrapv.
Written by Falk Hueffner, 20th May 2004. */
/* { dg-do run } */
/* { dg-options "-ftrapv" } */
__attribute__((noinline)) int
mulv(int a, int b)
{
return a * b;
}
int
main()
{
mulv( 0, 0);
mulv( 0, -1);
mulv(-1, 0);
mulv(-1, -1);
return 0;
}