🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #6266

Re: Does ANSI insist this is legal?

#6266
From: Walter Murray
Date: Thu, 01 Mar 1990 16:43
19 lines
1064 bytes
Ronald Guilmette asks:

> 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; }

No.  Setting aside the question of whether a pointer can fit in a char
or a short, this code violates Section 3.4:  "Cast operators in an
arithmetic constant expression shall only convert arithmetic types
to arithmetic types, except as part of an operand to the sizeof
operator."

Walter Murray
----------
Technical Details
Message-ID: <12570047@hpclwjm.HP.COM>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!brutus.cs.uiuc.edu!jarthur!elroy.jpl.nasa.gov!decwrl!shelby!unix!hplabs!hp-ses!hpcuhb!hpcllla!hpclisp!hpclwjm!walter
References: <25EB8750.5286@paris.ics.uci.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!brutus.cs.uiuc.edu!jarthur!elroy.jpl.nasa.gov!decwrl!shelby!unix!hplabs!hp-ses!hpcuhb!hpcllla!hpclisp!hpclwjm!walter
From: walter@hpclwjm.HP.COM (Walter Murray)
Newsgroups: comp.std.c
Subject: Re: Does ANSI insist this is legal?
Message-ID: <12570047@hpclwjm.HP.COM>
Date: 1 Mar 90 16:43:26 GMT
References: <25EB8750.5286@paris.ics.uci.edu>
Organization: Hewlett-Packard Calif. Language Lab
Lines: 19