What's an LValue [was A quick question]

Chris Torek torek at elf.ee.lbl.gov
Sat Mar 16 17:28:24 AEST 1991


In article <2647 at travis.csd.harris.com> sean at hcx2.ssd.csd.harris.com
(Sean Burke) writes:
>So where would:
>
>   struct { int array[10] ; } func() ;
>
>   func().array[k]
>
>fit into these rules?
>
>I guess you could argue that its covered becuase
>
>  func().array
>
>is implicitly taking the address of something that is not an lvalue,
>and thats an error in itself.

This is correct.  X3.159-1989%, p. 40:

	A postfix expression followed by a dot . and an identifier
	designates a member of a structure or union object. ... is
	an lvalue if the first expression is an lvalue.

Thus, `func().array' denotes something that is not an lvalue but would
(if it existed) be a value of type `array N of ...'.  Since no such
type exists, it is clear that no expression of the form func().array
exists. :-)

Seriously: the value from func() is an `rvalue' structure and an attempt
to name its `array' member is illegal.  GCC permits it as an extension.
-----
% Actually, I am still using a 1988 draft.
-- 
In-Real-Life: Chris Torek, Lawrence Berkeley Lab CSE/EE (+1 415 486 5427)
Berkeley, CA		Domain:	torek at ee.lbl.gov



More information about the Comp.lang.c mailing list