Yes it is nasty in more than one way, because a C++ Boolean <> a C Boolean.
In C++ Boolean is a dedicated type true/false, so !false == true and ONLY true.
(! is not, negation)
whereas in C it depends, but in modern C it is usually 0 or 1 and in older C it is 0 or any other value than 0.
C knows _Bool and from C99 bool which also resolve to 0 and 1.
Usually through stdbool.h.
Since Pascal also defines them as 0 and 1 one would expect interoperability, but that is not always the case because of optimization issues. We discussed that fairly recently. E.g. the clang compiler optimizes bool true into values other than 1 even if it is defined as 1 in the language. This can lead to problems when interfacing C code and Pascal code.
The mentioned discussion contains some C code by me that demonstrates the issue: in -O1 it is 0 and 1, as expected, but in -O4 it is 0 and any other value the compiler feels like using. There was even a deranged proposal to "fix" this at the fpc side, meaning changing the Pascal language definition of Boolean.
The best way to solve the issue is indeed like in the C++ code above: the negation is probably to avoid the 0/1 optimization paradox and you can use the same in Pascal. Basically testing for true is testing not 0 and so in the case of the ternary operator we do not test for 1. This looks like black magic at first, but it works to avoid the optimization issue. It took me quite a while to realize what was happening and why.
The condition is implicitly converted to bool in any case, so I think this is just an oversight by the author; it's perfectly possible to invert the outcome just by swapping the ternary operands.
It is intentional and not an oversight at all: the programmer of that C++ code was obviously aware of the issue.
Nasty: the only thing you can be sure of is false!
Its first negating the operation and then follows the actual selection.
I don't know why it just didn't swap the selections around!
or maybe I still have it wrong!
I hope it now makes sense to you too.
This is the same thing:
No it isn't, because any other value than all $F's would negate to another value <> 0 (keeps being true), so if you want to really test for true and in all cases, you have to test for not false (0) and that is exactly why that C++ code looks like it does.
This also resolves the previous discussion.
The only way to reliably test for true in a compiler and optimization independent way is to test for not false.
(The hell with language definitions and just testing for bit 0 being set or not. If you are a compiler writer, simply ignore that!)