Newsgroups: comp.std.c++ Path: utzoo!utgpu!news-server.csri.toronto.edu!torsqnt!geac!alias!rae From: rae@alias.com (Reid Ellis) Subject: Re: Assignment operators return lvalues / classes and types Message-ID: <1991Apr27.161946.953@alias.com> Keywords: assignment, lvalue, class, type Sender: news@alias.com (USENET News) Organization: Alias Research, Inc. Toronto ON Canada References: <950@edg1.UUCP> <1991Apr24.184018.23427@kestrel.edu> <1991Apr25.030006.5849@csi.uottawa.ca> Date: Sat, 27 Apr 91 16:19:46 GMT Martin Hitz writes: >struct X { int i; }; >X f() { X x; return x; } >main() >{ > int i = f().i; // OK > X x; > f() = x; // !OK >} > >f() does NOT return an lvalue I would have thought that f() *does* return an lvalue, albeit in the form of a temporary variable. Note that the following *does* work: #include struct X { int i; }; X f() { X x; x.i=12; return x; } main() { X x; x.i = 23; X & xref = f(); cout << "xref is " << xref.i << '\n'; xref = x; cout << "x is " << x.i << ", while xref is now " << xref.i << '\n'; } The output from this is xref is 12 x is 23, while xref is now 23 So it would seem that your [and my!] version of cfront is broken.. Reid -- Reid Ellis 1 Trefan Street Apt. E, Toronto ON, M5A 3A9 rae@utcs.toronto.edu || rae@alias.com CDA0610@applelink.apple.com || +1 416 362 9181 [work]