Does ANSI insist this is legal?
Henry Spencer
henry at utzoo.uucp
Thu Mar 1 05:09:14 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;
> int main () { return 0; }
Holy Scriptures, Oct 88 draft, verse 3.3.4:
A pointer may be converted to an integral type. The size of
integer required and the result are implementation-defined.
If the space provided is not long enough, the behavior is
undefined.
Your program falls under the jurisdiction of that last sentence, since
it is vanishingly unlikely that a pointer will fit in a char and not too
likely nowadays that it will fit in a short. So the compiler can remove
all your files, send rude mail to your boss, and dump core if it wants.
--
"The N in NFS stands for Not, | Henry Spencer at U of Toronto Zoology
or Need, or perhaps Nightmare"| uunet!attcan!utzoo!henry henry at zoo.toronto.edu
More information about the Comp.std.c
mailing list