On 2026-11-23, Scott Lurndal <sco…@slp53.sl.home> wrote:
> Simon Clubley <club…@remove_me.eisner.decus.org-Earth.UFP> writes:
>>>
>> >>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.
> > Must disagree. Consider the classic (ptr && *ptr) paradigm. >
>> >>It depends on the compiler behaving as expected
> > No, it depends on the programmer being familiar with > the C (and C++) language grammar. >
Or the programmer is familiar with it but doesn't like it in the same way that he doesn't like in-band null string terminators or (in C++) he doesn't like the decision for default speed over safety ([] is unchecked instead of checked and you have to use at() for safe access). All those are examples of my mindset here BTW. In that latter case, you should have got safety by default and if you wanted speed you should have had to ask for it.
> The chance that any C compiler (outside of a first year college > course) would not properly handle those operators correctly > is exactly zero. >
As in my original posting, the problem could also be introduced at application level during an edit.
>
>>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).
> > Seriously, use the conditonal logical operators frequently and > often. They'll work correctly unto the heat death of the universe. >
>> >>Oh, and before you all start mocking me, please read this: >> >>https://www.redhat.com/en/blog/security-flaws-caused-compiler-optimizations
> > That has nothing to do with the conditional-and/or operators. >
It does if you understand the point I am trying to make. Simon.
-- Simon Clubley, club…@remove_me.eisner.decus.org-Earth.UFP Walking destinations on a map are further away than they appear.