🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #4256

Re: Comma operator in constant expression

#4256
From: Christopher R. Volpe
Date: Fri, 20 Oct 1995 12:46
49 lines
2375 bytes
In article <Pine.ULT.3.91.951019204530.7241B-100000@mars.dsv.su.se>, Jens M Andreasen <jens-and@dsv.su.se> writes:
>static int i = 1 ? 3 : ( 1, 2);
>
>On 19 Oct 1995, Norman Diamond wrote:
>
>> No, after parsing the expression, the compiler ends up with something like:
>> 1 ? 3 : (1, 2);
>
> 1  The programmer tells that the condition is always thrue. So there is no 
> ?  condition left for the compiler to evaluate? Fine, then don't! At this
>    stage the ? operator is reduced to an elegant illusion.
> 3  This constant is for real.
> :
> (  Start of parenthesis, hmmm , interresting ...
> 1  Now, what to do with this? Consider it done and gone .
> ,  (and this cute little comma goes down the drain as well :)
> 2  This constant would have been the value of the parenthesized expression
> )  if the condition had been explicitly false.
>
>So at this stage the compiler will be left with one welldefined constant. 
>It did not even have to compute it ...



How is any of the above relevant? You've merely demonstrated that the above
expresion can be computed at compile time. You haven't demonstrated that the
expression is permitted there in the first place. Others have demonstrated
that it isn't permitted, because comma operators are not allowed in constant
expressions.

>
>> The question is not the result of evaluating the expression, the question is
>> whether the expression is permitted.  ...
>---------------------------------<snip>--------------------------------
>
>A constant is permitted, right?

Yep. Too bad we don't have one.






--

Chris Volpe				Phone: (518) 387-7766 (Dial Comm 8*833
GE Corporate R&D			Fax:   (518) 387-6560
PO Box 8, Schenectady, NY 12301		Email: volpecr@crd.ge.com
Technical Details
Message-ID: <4685n3$l8k@rdsunx.crd.ge.com>
Path: arc1-ca.pugleaf.net!bart.crd.ge.com!volpe
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>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!bart.crd.ge.com!volpe
From: volpe@bart.crd.ge.com (Christopher R. Volpe)
Newsgroups: comp.std.c
Subject: Re: Comma operator in constant expression
Date: 20 Oct 1995 12:46:27 GMT
Organization: GE Corporate Research & Development
Sender: volpe@bart (Christopher R. Volpe)
Distribution: world
Message-ID: <4685n3$l8k@rdsunx.crd.ge.com>
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>
Reply-To: volpe@ausable.crd.ge.com
NNTP-Posting-Host: bart.crd.ge.com