Article View: comp.std.c
Article #4258Re: Comma operator in constant expression
From: Dan Pop
Date: Fri, 20 Oct 1995 18:20
Date: Fri, 20 Oct 1995 18:20
33 lines
1989 bytes
1989 bytes
In <Pine.ULT.3.91.951020083514.12953B-100000@mars.dsv.su.se> Jens M Andreasen <jens-and@dsv.su.se> writes: > >On 19 Oct 1995, Peter Seebach wrote: > >> In article <Pine.ULT.3.91.951019204530.7241B-100000@mars.dsv.su.se>, >> Jens M Andreasen <jens-and@dsv.su.se> wrote: >> Re: >static int i = 1 ? 3 : ( 1, 2); >> >> >I interprete that as a way of saying that you are allowed to obfuscate >> >your constants any way you like, as long as they remain constants. There is >> >nothing in the expression above that could ever be nothing but a constant. >> >> Except that the standard *EXPLICITLY* says that a "constant expression" >> *CANNOT* contain a , operator. Period. > >Period what? I did an example parsing showing that the comma will >disappear , vanish, go out of existence, DIE, or whatever parafrase ... Nope. It won't disappear _before_ the compiler "sees" it. And it will see it in a context where only a _constant expression_ is allowed. But constant expressions can't contain the comma operator (the standard says so) hence the compiler MUST emit a diagnostic for that translation unit. What is so difficult to understand? Dan -- Dan Pop CERN, CN Division Email: Dan.Pop@mail.cern.ch Mail: CERN - PPE, Bat. 31 R-004, CH-1211 Geneve 23, Switzerland
Technical Details
Message-ID:
<danpop.814213231@rscernix>Path:
arc1-ca.pugleaf.net!CERN.ch!rscernix!danpopReferences:
<45uevf$d99@news0.rain.rg.net> <Pine.ULT.3.91.951017124752.2343A-100000@mars.dsv.su.se> <464s1t$lb4@usenet.pa.dec.com> <Pine.ULT.3.91.951019204530.7241B-100000@mars.dsv.su.se> <466v8b$2em@solutions.solon.com> <Pine.ULT.3.91.951020083514.12953B-100000@mars.dsv.su.se>Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c Path: arc1-ca.pugleaf.net!CERN.ch!rscernix!danpop From: Dan.Pop@mail.cern.ch (Dan Pop) Subject: Re: Comma operator in constant expression X-Nntp-Posting-Host: ues5.cern.ch Message-ID: <danpop.814213231@rscernix> Sender: news@news.cern.ch (USENET News System) Organization: CERN European Lab for Particle Physics X-Newsreader: NN version 6.5.0 #7 (NOV) References: <45uevf$d99@news0.rain.rg.net> <Pine.ULT.3.91.951017124752.2343A-100000@mars.dsv.su.se> <464s1t$lb4@usenet.pa.dec.com> <Pine.ULT.3.91.951019204530.7241B-100000@mars.dsv.su.se> <466v8b$2em@solutions.solon.com> <Pine.ULT.3.91.951020083514.12953B-100000@mars.dsv.su.se> Date: Fri, 20 Oct 1995 18:20:31 GMT