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: Wed, 13 May 2026 11:37:05 -0700 Organization: A noiseless patient Spider Lines: 40 Message-ID: <86mry3jgvi.fsf@linuxsc.com> References: <10su8cn$am9i$1@dont-email.me> <868q9ppg4o.fsf@linuxsc.com> <10tu7mi$126$1@reader1.panix.com> <864ikdp9lk.fsf@linuxsc.com> <10tvdd7$ofi$1@reader1.panix.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Date: Wed, 13 May 2026 18:37:06 +0000 (UTC) Injection-Info: dont-email.me; logging-data="3026765"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+Y2pn+m7dfA49nYz5+4u8NYX5Q3Z8vK/o="; posting-host="ace8b6eaa328dcf44f89a3207699c4cb" User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux) Cancel-Lock: sha1:v2+rzCwSoYiCbqXV7kZlDblKIh8= sha1:0dCN4po3jB7tcpTB+rIDuNdmNGw= sha256:nwDYPuMTna0DPQDiijS+Kxhh0+nRHjKTHK7PJct3qTo= sha1:CR/OfIWgcyHZHyIT2Jq0/Vncsmo= Xref: csiph.com comp.lang.c:398894 cross@spitfire.i.gajendra.net (Dan Cross) writes: > In article <864ikdp9lk.fsf@linuxsc.com>, > Tim Rentsch wrote: > >> cross@spitfire.i.gajendra.net (Dan Cross) writes: >> >>> In article <868q9ppg4o.fsf@linuxsc.com>, >>> Tim Rentsch wrote: >>> >>>> antispam@fricas.org (Waldek Hebisch) writes: >>>> >>>> [discussing the notion of "safe" programs] >>>> >>>>> As I wrote, safety is about ability to avoid or detect errors. >>>> >>>> In the functional programming community the usual statement is >>>> "Well-typed programs cannot go wrong." >>> >>> This is only concerning _type safety_. >> >> I didn't mean to imply anything different. > > Looking at what you wrote: > > |I think a good way of understanding this is that, if > |a program stays inside the safe limits of the language, > |the program can produce wrong answers, but it cannot > |produce meaningless answers. > > You are wrong. > > A well-typed program _can_ produce meaningless answers; those > answers will have a well-defined type, but it is impossible to > say whether the value produced has any meaning with respect to > the program's intended purpose. Moreover, the "safe limits of > the lanugage", whatever those may be, have nothing to do with > it. What you mean by meaningless isn't what I meant by meaningless.