union *func()

Guido van Rossum guido at cwi.nl
Mon Oct 31 22:43:52 AEST 1988


In article <7686 at boring.cwi.nl> I wrote:
>Chris's original posting said that "v = func().a" is legal, unless a is
>an array.  The reason was that C has no array assignment, not that
>there's anything special with array members of structs returned by
>functions.  A less confusing way to state the rules is that "func().a" is
>legal, but as an rvalue only.

I received a mail message stating that in fact *any* use of func().a is
illegal when a is an array member; the reason being that this use of an
array name requires conversion to a pointer to its first element, and of
course Chris has adequately explained why that should be illegal.

I suppose that it is thus even illegal to write something like
"v = func().a[0]", even though that would make perfect sense (all
Chris's examples showed cases where a's address or the address of some
element was actually saved).  I suppose it would be possible to change
various rules about pointers, arrays, rvalues and lvalues to fix this,
but nobody cared.
--
Guido van Rossum, Centre for Mathematics and Computer Science (CWI), Amsterdam
guido at piring.cwi.nl or mcvax!piring!guido or guido%piring.cwi.nl at uunet.uu.net



More information about the Comp.std.c mailing list