is f().c legal? How about (&(f()))->c ?
David Lai
lai at vedge.UUCP
Sat Jan 28 07:12:15 AEST 1989
Here f() returns a structure.
I am trying to figure out why C compilers like the latter expression
and cant handle the first expression. From what I gather from the
ANSI specs, it says that a function call is not an lvalue (*). Therefore
the latter expression should be illegal (& requires an lvalue).
As far as I can tell the first expression is legal... the . operator
anly requires that the left hand side be a struct or union, it does not
have to be an lvalue.
So why is it that the C compilers (Sun and HP-UX's) both complain that
the expression f().c is illegal, but run fine on (&(f()))->c.
Seems to me that the logic is reversed here.
(*) I got that info from Harbinson and Steele. I have the May Draft of ANSI,
but cant find the page where it mentions that. Can anyone point me to
the appropriate ANSI section number?
--
"What is a DJ if he can't scratch?" - Uncle Jamms Army
The views expressed are those of the author, and not of Visual Edge, nor Usenet.
David Lai (vedge!lai at larry.mcrcim.mcgill.edu || ...watmath!onfcanim!vedge!lai)
More information about the Comp.std.c
mailing list