Thread View: gnu.gcc.bug
1 messages
1 total messages
Started by Paul Eggert
Thu, 05 Nov 1992 02:02
fold-const.c contains an integer overflow (GCC 2.3.1)
Author: Paul Eggert
Date: Thu, 05 Nov 1992 02:02
Date: Thu, 05 Nov 1992 02:02
36 lines
1844 bytes
1844 bytes
Here is a patch to a typo in fold-const.c (GCC 2.3.1, sparc). On a sparc, the
expression (HOST_WIDE_INT) 1 << (HOST_BITS_PER_WIDE_INT - 1) evaluates to
1<<31, which is a signed integer overflow. Replacing it with (-1)<<31 fixes
the problem.
This is the only constant expression signed integer overflow that I found in
GCC 2.3.1 itself (sparc, SunOS 4.1.2).
Thu Nov 5 01:53:38 1992 Paul Eggert (eggert@twinsun.com)
* fold-const.c (fold_convert): Avoid signed integer overflow in 1<<N.
===================================================================
RCS file: fold-const.c,v
retrieving revision 2.3.1.5
retrieving revision 2.3.1.6
diff -c -r2.3.1.5 -r2.3.1.6
*** fold-const.c 1992/11/05 01:27:21 2.3.1.5
--- fold-const.c 1992/11/05 01:53:38 2.3.1.6
***************
*** 1530,1536 ****
if (d >= (REAL_VALUE_TYPE) half_word * half_word / 2)
{
low = d - (REAL_VALUE_TYPE) half_word * half_word / 2;
! low |= (HOST_WIDE_INT) 1 << (HOST_BITS_PER_WIDE_INT - 1);
}
else
low = (HOST_WIDE_INT) d;
--- 1530,1536 ----
if (d >= (REAL_VALUE_TYPE) half_word * half_word / 2)
{
low = d - (REAL_VALUE_TYPE) half_word * half_word / 2;
! low |= (HOST_WIDE_INT) -1 << (HOST_BITS_PER_WIDE_INT - 1);
}
else
low = (HOST_WIDE_INT) d;
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads