This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[3.4 PATCH] PR other/15526: Backport from mainline
- From: Roger Sayle <roger at eyesopen dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: Mark Mitchell <mark at codesourcery dot com>
- Date: Sun, 26 Sep 2004 11:22:28 -0600 (MDT)
- Subject: [3.4 PATCH] PR other/15526: Backport from mainline
The following patch is a backport of Falk Hueffner's fix for
PR other/15526, which is a fix for a runtime abort on -1*0
when compiling with -ftrapv.
The patch below has been tested against the gcc-3_4-branch on
i686-pc-linux-gnu with a full "make bootstrap", and regression
tested with a top-level "make -k check" with no new failures.
Ok for the gcc-3_4-branch?
2004-09-26 Roger Sayle <roger@eyesopen.com>
PR other/15526
Backport from mainline
2004-05-20 Falk Hueffner <falk@debian.org>
* libgcc2.c (__mulvsi3): Fix overflow test.
* gcc.dg/ftrapv-1.c: New test case.
Index: libgcc2.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/libgcc2.c,v
retrieving revision 1.170.6.1
diff -c -3 -p -r1.170.6.1 libgcc2.c
*** libgcc2.c 17 Jul 2004 21:18:47 -0000 1.170.6.1
--- libgcc2.c 26 Sep 2004 15:13:59 -0000
*************** __mulvsi3 (Wtype a, Wtype b)
*** 130,138 ****
{
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)))
abort ();
return w;
--- 130,136 ----
{
const DWtype w = (DWtype) a * (DWtype) b;
! if ((Wtype) (w >> WORD_SIZE) != (Wtype) w >> (WORD_SIZE - 1))
abort ();
return w;
/* 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;
}
Roger
--
Roger Sayle, E-mail: roger@eyesopen.com
OpenEye Scientific Software, WWW: http://www.eyesopen.com/
Suite 1107, 3600 Cerrillos Road, Tel: (+1) 505-473-7385
Santa Fe, New Mexico, 87507. Fax: (+1) 505-473-0833