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 08:41:41 -0700 Organization: A noiseless patient Spider Lines: 18 Message-ID: <867bpfuszu.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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Date: Thu, 07 May 2026 15:41:42 +0000 (UTC) Injection-Info: dont-email.me; logging-data="2282973"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18TfwG4DGZXr4xuIzl3levdTZdZhT8yYrU="; posting-host="a025a3924a4370d705b785ca24b22822" User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux) Cancel-Lock: sha1:BN2qFA5Iah44dA2j3TyWVpxuHk0= sha1:ERjopPQaFwMf1tISEgWhKMQmutQ= sha256:TP0Py8Kx7NCHAViPln//W3zVE/p5eCY/2KTzszst8LY= sha1:qUioEY9Txq1yC5k528VaucWdInw= Xref: csiph.com comp.lang.c:398453 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.