On 11/23/2026 2:42 PM, Simon Clubley wrote:
> On 2026-11-20, Arne Vajhøj <ar…@vajhoej.dk> wrote:
>> On 11/20/2026 3:10 PM, Simon Clubley wrote:
>>> On 2026-11-20, Arne Vajhøj <ar…@vajhoej.dk> wrote:
>>>> And for the curious - before fix: >>>> >>>> use_ssl = resource->scheme && (ZSTR_LEN(resource->scheme) > 4) && >>>> ZSTR_VAL(resource->scheme)[4] == 's';
>>> >>> I really hope that line was always compiled by a short-circuiting >>> compiler and that line always successfully triggered short-circuiting...
>> Doesn't C require/mandate short circuiting in cases like this?? >>
> > 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. > > 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).
In general coding to protect against potential compiler bugs seems futile to me. Compiler bugs does happen, but this seems like a very unlikely one to happen. I know unlikely <> impossible, but preparing for unlikely compiler bugs does not make sense to me. I would be more attracted to the readability argument. That: IF e1 AND e2 THEN ... END IF would be more readable as: IF e1 THEN IF e2 THEN ... END IF END IF Because even though it seems highly unlikely that compiler writers does not know the rules for short circuit in the language they are implementing, then it could definitely happen that the application writer using the compiler does not. Arne