🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #5684

is f().c legal? How about (&(f()))->c ?

#5684
From: David Lai
Date: Fri, 27 Jan 1989 21:12
23 lines
1461 bytes
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@larry.mcrcim.mcgill.edu || ...watmath!onfcanim!vedge!lai)
Technical Details
Message-ID: <2648@vedge.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!bloom-beacon!mcgill-vision!iros1!vedge!lai

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!bloom-beacon!mcgill-vision!iros1!vedge!lai
From: lai@vedge.UUCP (David Lai)
Newsgroups: comp.std.c
Subject: is f().c legal?  How about (&(f()))->c ?
Keywords: ansi
Message-ID: <2648@vedge.UUCP>
Date: 27 Jan 89 21:12:15 GMT
Organization: Visual Edge Software, St. Laurent, Quebec
Lines: 23