Jack Klein <> writes:
> On 31 Aug 2005 11:36:14 -0700, Tim Rentsch <>
> wrote in comp.lang.c:
[...]
>> I propose "implicitly convertible". It's descriptive,
>> and accurate.
>>
>> Besides the confusion around "compatible", the term
>> "assignment compatible" suggests that the conversion
>> happens only for assignment (or function arguments);
>> whereas void pointers can also be used with non-void
>> pointers in other contexts, eg, equality comparisons,
>> or as one side of a ?: result set.
>
> What do you mean by equality comparisons? Are you implying code like
> this:
>
> #include <stdio.h>
>
> int main(void)
> {
> int x = 0;
> int *ip = &x;
> void *vp = &x;
> if (vp == ip)
> puts("they match");
> else
> puts("they don't");
> return x;
> }
>
> ...is valid?
I believe it is. Are you implying that it isn't?
C99 6.5.9 Equality operators:
Constraints
One of the following shall hold:
-- both operands have arithmetic type;
-- both operands are pointers to qualified or unqualified versions
of compatible types;
-- one operand is a pointer to an object or incomplete type and
the other is a pointer to a qualified or unqualified version of
void; or
-- one operand is a pointer and the other is a null pointer constant.
--
Keith Thompson (The_Other_Keith)
kst- <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.