Comma operator: lvalue????

diamond@tkovoa diamond at tkou02.enet.dec.com
Thu Aug 9 14:42:59 AEST 1990


In article <10839 at crdgw1.crd.ge.com> volpe at underdog.crd.ge.com (Christopher R Volpe) writes:

>Can someone with a copy of the standard tell me if the comma
>operator produces an lvalue. This is one of the only operators
>that K&R2 fails to mention whether or not it returns an lvalue.

The last draft of the standard puts it in a FOOTNOTE that the comma operator
does not produce an lvalue.  And because of the positioning of the footnote,
it is very easy to miss.  It is typographically correct but accidentally
ended up in a reader-unfriendly manner, so it looks like even K&R missed it!

>My intuition at first would tell me no, but the following works
>under GNU C:

In some cases, if a compiler provides an extension, it is still required
to issue a warning.  However, it seems that this extension does not require
a warning.  No syntax or constraints section seems to say which expressions
yield lvalues.

>I assume that if the comma operator EVER produces an lvalue, it does
>so if and only if the right operand is an lvalue. Is this correct?

Intuitively it's hard to imagine how the result could be an lvalue if the
right operand isn't an lvalue.  However, when you're asking what's correct,
you have to RTIFM (I == implementation's).

-- 
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.lang.c mailing list