Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!cmcl2!brl-adm!brl-smoke!gwyn From: gwyn@brl-smoke.ARPA (Doug Gwyn ) Newsgroups: comp.lang.c Subject: Re: constant expression rules Message-ID: <6471@brl-smoke.ARPA> Date: Sat, 26-Sep-87 23:00:28 EDT Article-I.D.: brl-smok.6471 Posted: Sat Sep 26 23:00:28 1987 Date-Received: Sun, 27-Sep-87 11:58:27 EDT References: <3018@ulysses.homer.nj.att.com> Reply-To: gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 11 Keywords: portability In article <3018@ulysses.homer.nj.att.com> ggs@ulysses.homer.nj.att.com (Griff Smith) writes: >The question is - what is a reasonable level of constant folding that >I can assume when trying to write portable code? The practical answer is, if you need to anticipate the actual behavior of a wide range of existing C compilers, you cannot count on very much! Generally, constant expressions involving just integers and the simple arithmetic operations are handled correctly by C compilers. Constant expressions involving much more, for example floating-point and casts, are only handled correctly by some implementations, although the forthcoming C standard promises that they are valid in initializers.