Article View: comp.std.c
Article #6247Re: Does ANSI insist this is legal?
From: Henry Spencer
Date: Wed, 28 Feb 1990 18:09
Date: Wed, 28 Feb 1990 18:09
23 lines
1312 bytes
1312 bytes
In article <25EB8750.5286@paris.ics.uci.edu> rfg@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@zoo.toronto.edu
Technical Details
Message-ID:
<1990Feb28.180914.27504@utzoo.uucp>Path:
arc1-ca.pugleaf.net!utzoo!henryReferences:
<25EB8750.5286@paris.ics.uci.edu>Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c Path: arc1-ca.pugleaf.net!utzoo!henry From: henry@utzoo.uucp (Henry Spencer) Subject: Re: Does ANSI insist this is legal? Message-ID: <1990Feb28.180914.27504@utzoo.uucp> Organization: U of Toronto Zoology References: <25EB8750.5286@paris.ics.uci.edu> Date: Wed, 28 Feb 90 18:09:14 GMT