I believe that to be standards compliant unsigned integers are /required/ to 
wrap without warning.
Signed integers can do whatever they want, including, in the final resort, even 
behaving sensibly. 


Best wishes / Mejores deseos /  Meilleurs vœux

Ian ... 

    On Thursday, April 21, 2022, 02:55:16 PM GMT+2, Paul Gilmartin 
<00000014e0e4a59b-dmarc-requ...@listserv.uga.edu> wrote:  
 
 On Apr 21, 2022, at 06:43:24, Seymour J Metz wrote:
> 
> The problem is detecting overflow.
>  
Correct.

I have worked with a couple C implementations for s/370 (from
suppliers other than IBM) which documented a requirement that
Integer overflow interruption be disabled by program mask.

Why?  This deprives the programmer of valuable overflow
detection, a behavior permitted by the Standard.  Simply,
the compiler should generate AL and SL for unsigned
operations.

> ________________________________________
> From: Robin Vowels
> Sent: Wednesday, April 20, 2022 10:38 PM
> 
>> C programmers don't give a damn about overflows.  An unfortunate consequence,
>> probably, of hardware architectures which, unlike 360, lack unsigned
>> instructions, forcing compilers to generate signed instructions for
>> unsigned operations.
> 
> I think that you will find that in machines that store negative values
> in two's complement form will produce a correct sum (or difference)
> using "signed" instructions, since all 32 bits* participate in the
> addition (or subtraction.
> 
> On the S/360, the AL and SL instructions set the condition code
> differently from A and S, but the 32-bit sum or difference is the same
> as A and S.

-- 
gil
  

Reply via email to