Path: csiph.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail From: Tim Rentsch Newsgroups: comp.lang.c Subject: Re: Safety of casting from 'long' to 'int' Date: Tue, 12 May 2026 19:02:42 -0700 Organization: A noiseless patient Spider Lines: 16 Message-ID: <8633zwm5h9.fsf@linuxsc.com> References: <10su8cn$am9i$1@dont-email.me> <10truhq$tqbj$1@dont-email.me> <10tt2cl$5lq$1@reader1.panix.com> <10ttem6$1daks$2@dont-email.me> <10tv8re$25l$1@reader1.panix.com> <10tvefc$1vmna$2@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Date: Wed, 13 May 2026 02:02:43 +0000 (UTC) Injection-Info: dont-email.me; logging-data="2494327"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+dwyddbDTefXQ2HqG3bl0Woi2f5lx5yQI="; posting-host="ace8b6eaa328dcf44f89a3207699c4cb" User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux) Cancel-Lock: sha1:66YumobOzRgetvmrUE0ay0QlPYU= sha1:SgEghZ9XWUg3/Gs+TzkJgT9Pc7U= sha256:Vt2nDcLmCZTC54MZx5g6wfBiYRpt/RC5imCkv/s0lLI= sha1:x+xUQlVdDXxWM7OD5I2/bE2G4Ww= Xref: csiph.com comp.lang.c:398838 scott@slp53.sl.home (Scott Lurndal) writes: > For the early C compiler on the PDP-11, the 'int' type was > 16-bits, implicitly signed, and the code generator simply emitted > available arithmetic instructions. > > It was the only C compiler at the time, any guarantees would have > been implicit in the choice of target architecture. > > I mostly wrote unix kernel code using the v6 compiler, rather than > writing code that did any heavy math, so whether value was > preserved or sign was preserved wasn't something I, as a kernel > programmer, routinely considered. If int was only 16 bits, I expect promotion considerations didn't come up very often.