Re: [Libclc-developers] Some more comments to the current CVS tree
Status: Planning
Brought to you by:
augestad
|
From: regis <re...@in...> - 2003-04-02 16:45:58
|
Jan Engelhardt wrote:
>
> Hi there,
>
> whilst looking through the current CVS snapshots, I stumbled over these issues:
>
> doc/string/clc_stralloc.txt:
> char *s = clc_stralloc("foo", "bar", (char *)0);
>
> Can't we assume that NULL is (something casted) 0? Yet,
> NULL is defined as (void *)0, but that is not a big difference
> to (char *)0. Even (int *)0 would work, wouldn't it?
No.
(char *)0 is an argument that is part part of the ellipsis
in the variadic function. So, there is no type conversion:
an arg of the exact type muist be pass, therefore the cast.
If a bare 0 is passed, then an int is passed, and
1) its sizeof may differ from the expected pointer
2) its zero-representation may not be the repr. of
the null pointer for this type. An implmentation may
decide e.g. that the hex value 0xDEADBEEF is the repr.
of a null pointer.
And the repr. of two null pointers for two different types
may differ.
|