Although I wouldn't have written it myself, what is the expected result of the following statement where A
(guaranteed to zero or positive integer) is greater than 1?
return A || 1;
In many languages, I would expect A
to be returned, unless the value of A
is zero, in which case 1 would be.
I don't have my C book to hand, but I note that in reality, the value 1 always seems to be returned. Is this a result of compiler optimisation or given the potential ambiguity of the expression, is it that the return value is non-deterministic?