🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Paul Eggert Tue, 01 Sep 1992 02:45
GCC 2.2.2's print-tree.c contains overflow in constant expression
#1033
Author: Paul Eggert
Date: Tue, 01 Sep 1992 02:45
39 lines
1789 bytes
GCC 2.2.2's print-tree.c contains an expression of the form
`1 << (HOST_BITS_PER_INT - 1)', which contains an arithmetic overflow,
and thus runs afoul of compilers that check for integer overflow in
expressions.

The expression in question is used merely to turn off the top bit of a
numerator to avoid problems with taking remainders of negative numbers;
a simple fix is to use unsigned remainder instead.  Here is a patch.
Another fix would be to replace `1 << (HOST_BITS_PER_INT - 1)' with
`(unsigned) 1 << (HOST_BITS_PER_INT - 1)'.

Mon Aug 31 20:09:29 1992  Paul Eggert  (eggert@twinsun.com)

	* print-tree.c (print_node): Avoid 1 << (HOST_BITS_PER_INT - 1),
	which overflows.

===================================================================
RCS file: print-tree.c,v
retrieving revision 2.2
diff -c -r2.2 print-tree.c
*** print-tree.c	1992/04/27 16:54:16	2.2
--- print-tree.c	1992/08/31 20:09:29
***************
*** 193,199 ****
        return;
      }
  
!   hash = ((int) node & ~(1 << (HOST_BITS_PER_INT - 1))) % HASH_SIZE;
  
    /* If node is in the table, just mention its address.  */
    for (b = table[hash]; b; b = b->next)
--- 193,199 ----
        return;
      }
  
!   hash = (unsigned) node % HASH_SIZE;
  
    /* If node is in the table, just mention its address.  */
    for (b = table[hash]; b; b = b->next)
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