Re: NULL vs 0

From: Alex Rousskov <rousskov_at_measurement-factory.com>
Date: Tue, 21 Sep 2010 13:16:42 -0600

On 09/21/2010 12:49 PM, Robert Collins wrote:
> On Wed, Sep 22, 2010 at 4:58 AM, Alex Rousskov
> <rousskov_at_measurement-factory.com> wrote:
>> Squid will most likely not work if NULL is not false. 0xCDCDCDCD is not
>> false. Consider:
>>
>> some_pointer = some_function_that_may_return_NULL();
>> if (!some_pointer)
>> ...
>
> When compilers do that, they also translate the if expression appropriately.
> But they are also meant to handle NULL vs 0 transparently in that case, AIUI.

Scary but good to know, thank you. Looks like 0xCDCDCDCD, if used as a
pointer, becomes false in that case!

Alex.
Received on Tue Sep 21 2010 - 19:16:44 MDT

This archive was generated by hypermail 2.2.0 : Wed Sep 22 2010 - 12:00:07 MDT