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).
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.
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).
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. :-)
Simon.
--
Simon Clubley, club…@remove_me.eisner.decus.org-Earth.UFP
Walking destinations on a map are further away than they appear.