🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #3169

Re: Voids in a comma expression

#3169
From: Norman Diamond
Date: Sat, 22 Jun 1991 06:14
32 lines
2105 bytes
In article <34405@shamash.cdc.com> paul@u02.svl.cdc.com (Paul Kohlmiller) writes:
>extern void foo(int x);
>j=(i=4,foo(i),i++);
>The diagnostic claims that ANSI disallows the void expression foo(i) in the
>command expression.

The diagnostic is wrong.

>ANSI 3.3.17 claims that the left operand is evaluated as
>a void. Does this mean the leftmost only?

It does.  In the expression   i=4,foo(i)
  i=4      is evaluated as a void;
  foo(i)   is evaluated, and the value of foo(i) is taken to be the value
    of i=4,foo(i).  The compiler seems to be confused because this value
    is void.  The value cannot be used in any way, but you're not using it.
    The value cannot be converted implicitly or explicity except to void
    (section 3.2.2.2), i.e. there is no prohibition against an implicit
    conversion to another void.

In the expression   i=4,foo(i),i++
  i=4,foo(i)   is evaluated as a void.  We just did this.
  i++          is evaluated and the result is the result of the expression.

>That seems wrong since only the rightmost operand really needs to be non-void.

The rightmost operand does not really need to be non-void.  If it did, then
the diagnostic would have been right.
--
Norman Diamond       diamond@tkov50.enet.dec.com
If this were the company's opinion, I wouldn't be allowed to post it.
Permission is granted to feel this signature, but not to look at it.
Technical Details
Message-ID: <1991Jun22.061414.7255@tkou02.enet.dec.com>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!crdgw1!uunet!cis.ohio-state.edu!sample.eng.ohio-state.edu!purdue!haven.umd.edu!decuac!nntpd.lkg.dec.com!tkou02.enet.dec.com!jit533!diamond
References: <34405@shamash.cdc.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!crdgw1!uunet!cis.ohio-state.edu!sample.eng.ohio-state.edu!purdue!haven.umd.edu!decuac!nntpd.lkg.dec.com!tkou02.enet.dec.com!jit533!diamond
From: diamond@jit533.swstokyo.dec.com (Norman Diamond)
Newsgroups: comp.std.c
Subject: Re: Voids in a comma expression
Keywords: voids comma operator
Message-ID: <1991Jun22.061414.7255@tkou02.enet.dec.com>
Date: 22 Jun 91 06:14:14 GMT
References: <34405@shamash.cdc.com>
Sender: usenet@tkou02.enet.dec.com (USENET News System)
Reply-To: diamond@jit533.enet@tkou02.enet.dec.com (Norman Diamond)
Distribution: usa
Organization: Digital Equipment Corporation Japan , Tokyo
Lines: 32