In article <11e4…@dont-email.me>, Simon Clubley <club…@remove_me.eisner.decus.org-Earth.UFP> wrote:
>On 2026-11-23, Dan Cross <cro…@spitfire.i.gajendra.net> wrote:
>> In article <11e2…@dont-email.me>, >> Simon Clubley <club…@remove_me.eisner.decus.org-Earth.UFP> wrote:
>>> >>>As Dan has pointed out, yes. However, I absolutely hate that style of >>>coding (and the use of short circuiting in general) - it is way too fragile. >>> >>>It depends on the compiler behaving as expected and it depends on someone >>>not making some edit change that happens to have the unexpected side-effect >>>of disabling any working short circuiting.
>> >> I'm going to have to push back on this. Short-circuiting of >> boolean operators, in C, is a defined part _of the language_ and >> is specified by an international standard. If a compiler is >> miscompiling them, then that's a compiler bug or a language that >> is not C. >>
>>>Seriously. Please consider not using short circuiting and instead writing >>>your code so it works regardless of whether your compiler short-circuits >>>or not. (Or it suddenly decides to stop short-circuiting one day).
>> >> This begs the question: what other parts of the language should >> we not use?
> >In C, I would like to see people stop using library functions that have >no way of doing bounded buffer copies (strcpy() and friends for example).
Ok, but those are _library functions_. Short-circuiting of operators is a defined part _of the language_, not of a library. The short circuiting behavior is mandated; it does not depend on a compiler's whims or optimization levels. If it is not there, the compiler is broken: period.
>I would say that is a common sense thing to ask for, but after some recent >CVEs it would appear common sense is not all that common. > >Here's one I just found with a search: > >https://www.tenable.com/cve/CVE-2026-80671 > >In C++, I would like to see people stop using unchecked bounds access >(ie: []) to access containers and start using checked access (ie: at()) >always instead. It's insane that [] wasn't the checked option so you got >safer code by default. > >BTW, I know some environments now allow [] to become checked. It would >be nice to see that left enabled in production code, especially in >today's environment.
I wasn't asking about C++, which is not the same language as C, but this is the same fundamental thing.
>Of course, what I would _really_ like is to see safer languages used in >our critical infrastructure. Said languages should also use readable >syntax to make it easier to learn (Ada is far better than Rust here >for example).
I agree that programmers should default to safe languages. Bluntly, very few people are qualified to program in systems languages. But I disagree that Ada is more readable than Rust, and I know other good judges who agree with me on that. Ada's syntax is overly verbose for no good reason; it gets in your way, which is an impediment to understanding. Further, I find its semantics wanting; we discussed the `'Valid` attribute here a while back, and I showed that it was both weaker than and less general than the `Result<T, E>` and `Option<T>` monads expressible with Rust's ADTs (and those of other languages).
>Another minor annoyance of mine. When you write code, you are modelling >a real-world problem. I hate that people sometimes run to using signed >integers by default when most of the time, unsigned integers are a more >accurate match. That's something that's more language-neutral however, >except when dealing with languages that have unexpected side effects with >mixed signed/unsigned expressions. :-)
This is agree with. - Dan C.