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: Thu, 07 May 2026 13:14:21 -0700 Organization: A noiseless patient Spider Lines: 25 Message-ID: <863403ugde.fsf@linuxsc.com> References: <10su8cn$am9i$1@dont-email.me> <10te56b$rpfu$1@dont-email.me> <10tfclh$7vb$1@reader1.panix.com> <10tflij$19d6u$1@dont-email.me> <10tg55j$kvp$1@reader1.panix.com> <10tgfs8$1i2g4$1@dont-email.me> <10thqam$1vfmr$1@kst.eternal-september.org> <10thu77$1v1r3$2@dont-email.me> <10ti57c$2234d$1@dont-email.me> <10ti6um$233oc$2@dont-email.me> <867bpfuszu.fsf@linuxsc.com> <10tipp9$2b782$1@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Date: Thu, 07 May 2026 20:14:22 +0000 (UTC) Injection-Info: dont-email.me; logging-data="2503768"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19X903Hcm6xGjcbAGpke3nyWMpUtpm7ELo="; posting-host="a025a3924a4370d705b785ca24b22822" User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux) Cancel-Lock: sha1:K8KuCuUORUy9kwHK9DmDAV1W4cc= sha1:hAm/Mn90LEH2vfwWttAIwhswubk= sha256:ABkEfHnj5lUgHjsvkkBFiQz+2LmPd1wG1dnVanb6eo4= sha1:UtHkJjODYDWCR4rw24NrxY4os3U= Xref: csiph.com comp.lang.c:398464 Bart writes: > On 07/05/2026 16:41, Tim Rentsch wrote: >> Bart writes: >> >> [...] >> >>> So, how would you describe overflow behaviour with [the option >>> -fwrapv] in place: UB, implementation defined, erroneous, >>> unspecified, or other? >> >> Undefined behavior is a static condition. If a particular construct >> is deemed undefined behavior by the C standard, it remains undefined >> behavior regardless of what compiler options are used, or how any >> particular compiler chooses to translate it. >> >>> What happens when someone runs my program without the options >>> stipulated? If it goes wrong, who's fault is that? >> >> Difficult question. Maybe a newsgroup comp.lang.c.blame should be >> started to address such questions. > > You're suggesting there's a fault in that program. [...] I am suggesting no such thing.