Comma operator: lvalue????
Christopher R Volpe
volpe at underdog.crd.ge.com
Wed Aug 8 04:05:19 AEST 1990
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.
My intuition at first would tell me no, but the following works
under GNU C:
main()
{
int a,b;
if (&a == &(a,b)) printf("I shouldn't see this\n");
if (&b == &(a,b)) printf(" Test 1: address-of works properly.\n");
(a,b)=4;
if (b==4) printf("Test 2: Assignment works properly.\n");
}
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?
(Oh, BTW, sorry I forgot to sign my previous post about the macros)
Chris Volpe
GE Corporate R&D
volpecr at crd.ge.com
More information about the Comp.lang.c
mailing list