Article 129610 of comp.os.vms: Path: nntpd.lkg.dec.com!denton.zko.dec.com!amartin From: amartin@denton.zko.dec.com (Alan H. Martin) Newsgroups: comp.os.vms,vmsnet.misc Subject: Re: C++ Question: why isn't label() an lvalue? Date: 19 Sep 1995 15:26:15 GMT Organization: DEC Lines: 30 Message-ID: <43mnen$us4@nntpd.lkg.dec.com> References: <1995Sep14.091737.299@thehulk> NNTP-Posting-Host: denton.zko.dec.com Xref: nntpd.lkg.dec.com comp.os.vms:129610 vmsnet.misc:4367 In article <1995Sep14.091737.299@thehulk> munroe@dmc.com writes: >DEC C++ question here. GCC allows this inside a class definition: [Applying ``&'' to the results of a struct-valued function call] >But DEC C++ 1.3 complains as follows: ... > return (str$compare(&label(), &v) == 0 ? SS$_NORMAL : >SQS$_NOTINSLOT) ; >................................^ >%CXX-E-NEEDLVALUE, In this statement, "label()" is not an lvalue, but occurs in >a context that requires one. The program does not conform to the ARM (or the 28-Apr-95 ANSI C++ draft, for that matter). ARM §5.3 (Unary Operators) states on p. 55, "The result of the unary & operator is a pointer to its operand. The operand must be a function, an lvalue, or a qualified-name. ..." Furthermore, ARM §5.2.2 (Function Call) states on p. 51, "A function call is an lvalue only if the result type is a reference". ``label()'' is a struct value - not a function, qualified-name or reference. You could store the results of calling label into a temporary variable. Or, you could define a jacket for str$compare (e.g. ``str_compare'') which takes arguments of type const ``DSC$DESCRIPTOR &'', and then call the jacket with ``label()''. (You could even overload str$compare). /AHM -- Alan Howard Martin AMartin@TLE.ENet.DEC.Com