Casting void - int question
Chris Torek
chris at umcp-cs.UUCP
Wed Oct 22 14:13:22 AEST 1986
It is amazing how much discussion one compiler bug can generate!
>In article <26 at orion.UUCP> heins at orion.UUCP (Michael T. Heins) writes:
>>
>>int fna() { }
>>
>>void fnb() { }
>>
>>int (*array[32])();
>>main() {
>> array[0] = fna;
>> array[1] = fnb; /* This won't work as-is. */
>>}
>>
>>I have tried things like
>> array[1] = (int (*)())fnb;
>>but this generates the message "operands of CAST have incompatible types".
The cast is correct, but the 4.1 and 4.2BSD compilers misunderstand
void functions. `void' types in these compilers tend to cause all
sorts of internal indigestion. This is a bug.
In article <393 at sdchema.sdchem.UUCP> tps at sdchema.UUCP (Tom Stockfisch) writes:
>The compiler rightly complains because
> void (*)()
>could conceivably be larger than
> int (*)()
>on some wierd machine.
This is true, but that does not mean the compiler should complain,
or at least not so vociferously. At most it should issue a warning.
Lint should note the cast as non-portable.
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7690)
UUCP: seismo!umcp-cs!chris
CSNet: chris at umcp-cs ARPA: chris at mimsy.umd.edu
More information about the Comp.lang.c
mailing list