Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!pasteur!ucbvax!hplabs!hpfcdc!mike From: mike@hpfcdc.HP.COM (Mike McNelly) Newsgroups: comp.std.c Subject: Re: is f().c legal? How about (&(f()))->c ? Message-ID: <12040012@hpfcdc.HP.COM> Date: 2 Feb 89 16:48:41 GMT References: <2648@vedge.UUCP> Organization: HP Ft. Collins, Co. Lines: 21 > 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. You're correct. We consider the behavior to be a bug, too. The problem of f().c has been fixed for release 6.5 on HP-UX Series 300 due to be released "real soon now". I have no information on the (&(f()))->c problem. Mike McNelly mike%hpfcla@hplabs.hp.com