Does ANSI insist this is legal?

Doug Gwyn gwyn at smoke.BRL.MIL
Thu Mar 1 00:55:28 AEST 1990


In article <25EB8750.5286 at paris.ics.uci.edu> rfg at paris.ics.uci.edu (Ronald Guilmette) writes:
>Must a strictly conforming ANSI C implementation be able to generate an
>executable program from the following?
>	int main ();
>	short s = (short) &main;
>	char c = (char) &main;

No -- a pointer is required to be interconvertable to some particular
implementation-defined integral type, not necessarily short or char.
Also note that the initializers violate the definition of a constant
expression and thus need not be supported by an implementation even if
short or char were the appropriate integer to hold a pointer value.



More information about the Comp.std.c mailing list