Obscure C code (was Re: Excessive optimization)

Brent Hilpert hilpert at cs.ubc.ca
Mon Dec 6 14:22:27 CST 2010


On 2010 Dec 6, at 5:47 AM, Christian Corti wrote:

> On Sat, 4 Dec 2010, Sean Conner wrote:
>>>> Of course, there's always "FT"[!!b]
>>>
>>> This doesn't change much because !!123 may still be 123 instead of 1.
>>
>>  Nope.  !b will turn 0 to 1, and anything not 0 to 0.
>>
>> 	!!-1  = !(!-1)  = !(0) = 1
>> 	!!123 = !(!123) = !(0) = 1
>> 	!!0   = !(!0)   = !(1) = 0
>
> According to the following (and I was only referring to this!):
> [...]
>> It was thus said that the Great Philip Pemberton once stated:
> [...]
>> > However: the compiler would still be correct to use the value 123
>> > instead of 1, thus that code may not work... So it's compiler
>
> !!-1   = !(!-1)   = !(0)   = 123
> !!123  = !(!123)  = !(0)   = 123
> !!0    = !(!0)    = !(123) = 0
>
> Whether that's correct behaviour or not was not the question.

Lame. It was the question.

You also said:
> Indeed, it's compiler dependent.

.. which is incorrect.

You're making excuses for yourself.




More information about the cctalk mailing list