man 3 switch

Michael Hennebry hennebry at web.cs.ndsu.nodak.edu
Thu Nov 19 02:32:46 UTC 2009


On Thu, 19 Nov 2009, Cameron Simpson wrote:

> On 16Nov2009 10:54, Rick Stevens <ricks at nerd.com> wrote:
> | Another example is that a null pointer (or the value "NUL") is not
> | necessarily zero, only that it is guaranteed to not point at any valid
> | datum.
>
> Actually, it requires it to behave like 0 in an arithmetic context.

More precisely, it's required to behave like 0 in a boolean context.
It's not allowed in any other arithmetic context.
1 + ptr is invalid if ptr is null.
1 + !!ptr is 1 if ptr is null.

> But it _doesn't_ require it to be stored as a zero in the machine
> memory. That's why I cringe whenever I see someone use calloc() or

-- 
Michael   hennebry at web.cs.ndsu.NoDak.edu
"Pessimist: The glass is half empty.
Optimist:   The glass is half full.
Engineer:   The glass is twice as big as it needs to be."




More information about the fedora-list mailing list