Do you have to cast void pointers when dereferencing them?

Guy Harris guy at auspex.UUCP
Sun Dec 18 08:46:11 AEST 1988


 >My assumption (about the dbANS) comes from the understanding that
 >different pointers can have different representations (on some machines).
 >To say that pointer_of_one_type = pointer_of_another_type is legal, the
 >code must know the type of the lvalue to put the rvalue into the proper
 >representation.  Is this not true?

Yes, it's true, and the compiler *does* know the type of the lvalue, so
it can generate code to do the implicit conversion properly.  Why is
this any different from

	int foo;
	float bar;

	bar = foo;

which also causes an implicit conversion from "int" to "float"?



More information about the Comp.lang.c mailing list