Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!sundc!pitstop!sun!gorodish!guy From: guy%gorodish@Sun.COM (Guy Harris) Newsgroups: comp.lang.c Subject: Re: constant expression rules Message-ID: <29194@sun.uucp> Date: Sat, 26-Sep-87 00:45:41 EDT Article-I.D.: sun.29194 Posted: Sat Sep 26 00:45:41 1987 Date-Received: Sun, 27-Sep-87 09:44:18 EDT References: <3018@ulysses.homer.nj.att.com> Sender: news@sun.uucp Lines: 20 Keywords: portability > The question is - what is a reasonable level of constant folding that > I can assume when trying to write portable code? Is this a bug or a > gotcha? This is a bug. Any reasonable and correct compiler will certainly include float -> int conversions, and *vice versa*, as operations that can be performed at compile time, as well as the usual sorts of floating-point and integer operations. The trouble is that PCC's code for doing folding of conversions of constants at compile time is very fragile, and if you don't arrange to have things done at the proper times, PCC ends up seeing trees with conversion operators, rather than constants, at the root and gets all ticked off at you. I have seen this sort of thing break several flavors of PCC (including CCI's 68K compiler; that one I fixed, for at least some of the cases). Unfortunately, fixes to one version may not fix other versions; some of the code in question lives in the machine-dependent portions of PCC. Guy Harris {ihnp4, decvax, seismo, decwrl, ...}!sun!guy guy@sun.c);g