Article View: comp.std.c
Article #1592Re: constant expressions
From: diamond
Date: Wed, 15 Aug 1990 01:54
Date: Wed, 15 Aug 1990 01:54
25 lines
1993 bytes
1993 bytes
In article <13550@smoke.BRL.MIL> gwyn@smoke.BRL.MIL (Doug Gwyn) writes: >Followup-To: comp.std.c++ I changed this to comp.std.c. Does everyone's inews do this to them? >In article <1916@tkou02.enet.dec.com> diamond@tkou02.enet.dec.com (diamond@tkovoa) writes: >>In article <5930@darkstar.ucsc.edu> daniel@terra.ucsc.edu () writes: >>>Should a translator identify 1-1 as ``a constant expression evaluating >>>to zero,'' (even absent optimization)? >>I have added comp.std.c to the distribution for this article, because >>the C standard is almost vague on this as well. >The C standard is not at all vague about this; see section 3.4. Yes, section 3.4 says that a constant expression CAN be evaluated during translation. It is sufficiently clear that the translator is NOT REQUIRED to do so. I think Daniel was asking if it has to be treated "as if" it were evaluated during translation, and Mr. Gwyn and I agree (for a change) on the likely answer. In order to avoid vagueness, however, the standard could have said that such expressions do have to be detected as constants even though they do not have to be compiled as constants. At least there does not seem to be a contradiction or other deviation from intended rules, but it does require guesswork. -- Norman Diamond, Nihon DEC diamond@tkou02.enet.dec.com This is me speaking. If you want to hear the company speak, you need DECtalk.
Technical Details
Message-ID:
<1923@tkou02.enet.dec.com>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rutgers!usc!sdd.hp.com!decwrl!bacchus.pa.dec.com!shlump.nac.dec.com!tkou02.enet.dec.com!diamondReferences:
<5930@darkstar.ucsc.edu> <1916@tkou02.enet.dec.com> <13550@smoke.BRL.MIL>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rutgers!usc!sdd.hp.com!decwrl!bacchus.pa.dec.com!shlump.nac.dec.com!tkou02.enet.dec.com!diamond From: diamond@tkou02.enet.dec.com (diamond@tkovoa) Newsgroups: comp.std.c Subject: Re: constant expressions Message-ID: <1923@tkou02.enet.dec.com> Date: 15 Aug 90 01:54:48 GMT References: <5930@darkstar.ucsc.edu> <1916@tkou02.enet.dec.com> <13550@smoke.BRL.MIL> Reply-To: diamond@tkou02.enet.dec.com (diamond@tkovoa) Followup-To: comp.std.c Organization: Digital Equipment Corporation Japan , Tokyo Lines: 25