🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #308

Re: constant expressions

#308
From: diamond
Date: Tue, 14 Aug 1990 04:05
19 lines
1601 bytes
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.  If C++ maintains
compatibility with C here, then my best guess is:
  A translator does not have to compute the constant expression at
compile time, but it does have to remember that the expression is
constant.  When the value is cast (or automatically converted) to a
pointer, the compiled code has to remember that it was a constant,
check if the computation yields zero, and if so then convert it to
a null pointer.
  In other words, it is not necessary to do optimization, but if it
is not done, the result has to be "as if" optimization were done. :-)
-- 
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: <1916@tkou02.enet.dec.com>
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!tut.cis.ohio-state.edu!pacific.mps.ohio-state.edu!zaphod.mps.ohio-state.edu!wuarchive!decwrl!bacchus.pa.dec.com!shlump.nac.dec.com!tkou02.enet.dec.com!diamond
References: <5930@darkstar.ucsc.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!tut.cis.ohio-state.edu!pacific.mps.ohio-state.edu!zaphod.mps.ohio-state.edu!wuarchive!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++,comp.std.c
Subject: Re: constant expressions
Message-ID: <1916@tkou02.enet.dec.com>
Date: 14 Aug 90 04:05:53 GMT
References: <5930@darkstar.ucsc.edu>
Reply-To: diamond@tkou02.enet.dec.com (diamond@tkovoa)
Followup-To: comp.std.c++,comp.std.c
Organization: Digital Equipment Corporation Japan , Tokyo
Lines: 19