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 05:26:34 -0700 Organization: A noiseless patient Spider Lines: 59 Message-ID: <865x4rlclh.fsf@linuxsc.com> References: <10su8cn$am9i$1@dont-email.me> <10ttem6$1daks$2@dont-email.me> <10tthov$1eenk$3@kst.eternal-september.org> <10tuhmt$1o3bp$1@dont-email.me> <10tvc31$mun$1@reader1.panix.com> <10tvdne$20o1q$2@dont-email.me> <86tssckos7.fsf@linuxsc.com> <10u1oem$2lcvh$2@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Date: Wed, 13 May 2026 12:26:34 +0000 (UTC) Injection-Info: dont-email.me; logging-data="2828553"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+3BSlwsaEAczL02Ee1uCkGSU3nBb9svlI="; posting-host="ace8b6eaa328dcf44f89a3207699c4cb" User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux) Cancel-Lock: sha1:5azUZG9FUrZ8oyk8ioya3Jfj+xE= sha1:omqjGhQqmcMqqZHqCG/qC1PUD3U= sha256:y/yzHZg345m2rVGBJZG+baZaRnyV3VARCUrHOPXwb10= sha1:eTVNKh1eDxS3ma7nopjKL30uyHs= Xref: csiph.com comp.lang.c:398869 Bart writes: > On 13/05/2026 03:48, Tim Rentsch wrote: > >> Bart writes: >> >> [.. I am cutting 100ish lines as they don't bear on my response ..] >> >>> Take for example C's set of operator precedences. >>> >>> The one for the ?: operator is particularly obscure, so in an >>> expression like one of these: >>> >>> a + b ? c - d : e * f >>> a ? b ? c : d ? e : f : g >>> >>> then parentheses would be used to make things clearer. (I haven't >>> check these are valid, but that is the point; it is hard to see!) >>> >>> But would shouldn't people be expected to learn the rules? Why is it >>> OK to 'revel' in not knowing the basics here, but not when unnecessary >>> UBs are involved where rules are harder and which depend on runtime >>> inputs? >> >> If you want people to take you seriously, you need to find more >> compelling examples. I am both familiar with and comfortable with >> the syntax of C expressions, and even I would never write such >> expressions as the two shown above. > > No? I actually had your posted examples in mind. I can't remember you > using parentheses. I can remember you not being sympathetic to readers > of your code and expected them to be as familiar with precedence as > you are. > > >> These lines look like they >> were written by someone in junior high school (or these days, >> probably elementary school). > > The lines are not meant to mean anything, just sequences of terms and > operators. You can think of them as exercises where you add > parentheses to make them unambiguous. > > A bit like adding punctuation here: > > "that that is is that that is not is not is that it it is" > >> Whether you mean to or not, this >> example gives the impression of offering a strawman argument, and >> it's only natural for people to react to that by dismissing your >> comments, or even dismissing them altogether. Is that what you >> want? To be dismissed? Or do you hope to actually communicate >> with people? If so I recommend looking for a better framing of >> your views and ideas. > > Now this is getting silly. Can no one here engage in a civil > discussion without reducing to insults and casting aspersions? I'm sorry my comments weren't of more help to you.