Path: 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 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 ----------