From: Douglas McIlroy <douglas.mcilroy@dartmouth.edu>
To: John Levine <johnl@taugh.com>
Cc: tuhs@tuhs.org, luther.johnson@makerlisp.com
Subject: [TUHS] Re: C history question: why is signed integer overflow UB?
Date: Fri, 15 Aug 2025 17:04:09 -0400 [thread overview]
Message-ID: <CAKH6PiWDFm_js5zZ_0zHC0HpABSJ0u0dRsiW8=dO-JhrbWN2bA@mail.gmail.com> (raw)
In-Reply-To: <20250815184408.E438DD7D00B1@ary.qy>
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
next prev parent reply other threads:[~2025-08-15 21:04 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 [this message]
2025-08-15 21:59 ` Dave Horsfall
2025-08-15 23:58 ` Luther Johnson
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='CAKH6PiWDFm_js5zZ_0zHC0HpABSJ0u0dRsiW8=dO-JhrbWN2bA@mail.gmail.com' \
--to=douglas.mcilroy@dartmouth.edu \
--cc=johnl@taugh.com \
--cc=luther.johnson@makerlisp.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).