constant expressions

diamond@tkovoa diamond at tkou02.enet.dec.com
Wed Aug 15 11:54:48 AEST 1990


In article <13550 at smoke.BRL.MIL> gwyn at 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 at tkou02.enet.dec.com> diamond at tkou02.enet.dec.com (diamond at tkovoa) writes:
>>In article <5930 at darkstar.ucsc.edu> daniel at 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 at tkou02.enet.dec.com
This is me speaking.  If you want to hear the company speak, you need DECtalk.



More information about the Comp.std.c mailing list