Harald said:
Mark wrote:
[...]
void *p;
int *x;
p = x;
x = p;
printf("p=%p, x=%p\n", p, (void *)x);
return 0;
}
When else is implicit conversion to 'void *' done, except assignment
like above written?
Basically everywhere except variable argument lists.
void* to/from function pointer is also not implicit.
Implementations commonly provide both implicit and explicit conversions
between void * and function pointers as extensions, and neither is
available in standard C.
Argh! My statement above was about as relevant as
void* to/from struct tm is also not implicit.
Except that conversion between void* and struct tm is a constraint
violation. There is no implicit conversion, so such a conversion
would have to done via a cast operator. C99 6.5.4p2-3 says:
Constraints
2 Unless the type name specifies a void type, the type name shall
specify qualified or unqualified scalar type and the operand shall
have scalar type.
3 Conversions that involve pointers, other than where permitted by
the constraints of 6.5.16.1, shall be specified by means of an
explicit cast.
Conversion between void* and a function pointer, as I just wrote
elsethread, violates no constraint, but its behavior is undefined (but
of course an implementation is free to define it).
Incidentally, it seems to me that paragraph 3 is superfluous; any case
where it would apply is already covered by other constraints.
--
Keith Thompson (The_Other_Keith) (e-mail address removed) <
http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"