The Unix Heritage Society mailing list
 help / color / mirror / Atom feed
From: Luther Johnson <luther.johnson@makerlisp.com>
To: Douglas McIlroy <douglas.mcilroy@dartmouth.edu>,
	John Levine <johnl@taugh.com>
Cc: tuhs@tuhs.org
Subject: [TUHS] Re: C history question: why is signed integer overflow UB?
Date: Fri, 15 Aug 2025 16:58:36 -0700	[thread overview]
Message-ID: <e96a6172-7268-0264-287b-7472c0416f8e@makerlisp.com> (raw)
In-Reply-To: <CAKH6PiWDFm_js5zZ_0zHC0HpABSJ0u0dRsiW8=dO-JhrbWN2bA@mail.gmail.com>

Relating this all to a Godel-ish classification of axiomatic systems, 
language definitions with undefined behavior may be perfectly 
consistent, but there is useful behavior that cannot be expressed in 
those languages, while languages with no undefined behavior but with 
lots of implementation-specific behavior can express much more, but with 
less consistency.

On 08/15/2025 02:04 PM, Douglas McIlroy wrote:
> Idle thought; There's been mention of 1's complement. If overflow is
> UB because of that possibility, maybe ==0 should be, too!
>
> Doug
>
> On Fri, Aug 15, 2025 at 2:44 PM John Levine <johnl@taugh.com> wrote:
>> It appears that Luther Johnson <luther.johnson@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


  parent reply	other threads:[~2025-08-15 23:58 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-15 17:17 [TUHS] C history question: why is signed integer overflow UB? Dan Cross
2025-08-15 17:31 ` [TUHS] " Luther Johnson
2025-08-15 17:36   ` Luther Johnson
2025-08-15 18:03     ` Warner Losh
2025-08-16  6:01       ` Lars Brinkhoff
2025-08-15 18:02   ` Nevin Liber
2025-08-15 18:25     ` Luther Johnson
2025-08-15 18:44       ` John Levine
2025-08-15 21:04         ` Douglas McIlroy
2025-08-15 21:59           ` Dave Horsfall
2025-08-15 23:58           ` Luther Johnson [this message]
2025-08-17  2:25 ` Clem Cole

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e96a6172-7268-0264-287b-7472c0416f8e@makerlisp.com \
    --to=luther.johnson@makerlisp.com \
    --cc=douglas.mcilroy@dartmouth.edu \
    --cc=johnl@taugh.com \
    --cc=tuhs@tuhs.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).