[TUHS] C history question: why is signed integer overflow UB?

John Levine johnl at taugh.com
Sat Aug 16 04:44:08 AEST 2025


It appears that Luther Johnson <luther.johnson at makerlisp.com> said:
>-=-=-=-=-=-
>
>I hear and understand what you're saying. I think what I'm trying to 
>point out, is that in C, as it was originally implemented, in 
>expressions "a + b", "a >> 1", "++a", C "does what the machine does". 

We just had the same argument in comp.arch and came to largely the same
conclusion.  While overflow behavior on any particular machine may be
predictable, there's no consistency from one machine to another,
particularly back when there were still one's complement machines
where people compiled C code (some of the Univac mainframes.)

It isn't all that predictable even on a single machine.  I know several
where overflow might or might not trap depending on a program-settable
status bit.

R's,
John


More information about the TUHS mailing list