🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.bug
Article #1367

missing cast to USItype in libgcc2.c

#1367
From: Paul Eggert
Date: Thu, 12 Nov 1992 02:59
34 lines
1537 bytes
A missing cast to (USItype) in libgcc2.c causes problems when sizeof(USItype)
> sizeof(int), because it subtracts 2^31 instead of adding it.  This bug was
discovered with the arithmetic overflow patches that I'll send in my next
message.  Here is a patch.

Thu Nov 12 02:44:18 1992  Paul Eggert  (eggert@twinsun.com)

	* libgcc2.c (__udiv_w_sdiv): Avoid overflow when sizeof(USItype) >
	sizeof(int).

===================================================================
RCS file: libgcc2.c,v
retrieving revision 2.3.1.1
retrieving revision 2.3.1.2
diff -c -r2.3.1.1 -r2.3.1.2
*** libgcc2.c	1992/11/06 11:59:59	2.3.1.1
--- libgcc2.c	1992/11/12 02:44:18	2.3.1.2
***************
*** 296,302 ****
  	  /* Divide (c1*2^32 + c0) by d */
  	  sdiv_qrnnd (q, r, c1, c0, d);
  	  /* Add 2^31 to quotient */
! 	  q += 1 << 31;
  	}
      }
    else
--- 296,302 ----
  	  /* Divide (c1*2^32 + c0) by d */
  	  sdiv_qrnnd (q, r, c1, c0, d);
  	  /* Add 2^31 to quotient */
! 	  q += (USItype) 1 << 31;
  	}
      }
    else
Technical Details
Message-ID: <9211120259.AA21156@farside.twinsun.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!charon.amdahl.com!pacbell.com!decwrl!netsys!agate!ames!sun-barr!cs.utexas.edu!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!twinsun.COM!eggert

Show Full Headers
Complete Article Headers
Newsgroups: gnu.gcc.bug
Path: arc1-ca.pugleaf.net!sparky!uunet!charon.amdahl.com!pacbell.com!decwrl!netsys!agate!ames!sun-barr!cs.utexas.edu!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!twinsun.COM!eggert
From: eggert@twinsun.COM (Paul Eggert)
Subject: missing cast to USItype in libgcc2.c
Message-ID: <9211120259.AA21156@farside.twinsun.com>
Sender: gnulists@ai.mit.edu
Organization: GNUs Not Usenet
Distribution: gnu
Date: Thu, 12 Nov 1992 02:59:34 GMT
Approved: bug-gcc@prep.ai.mit.edu
Lines: 35