Topic: 8.4.3 -- references & non-lval


Author: fjh@munta.cs.mu.OZ.AU (Fergus Henderson)
Date: Sat, 11 Dec 1993 04:51:48 GMT
Raw View
Markus_Mauhart@m4.maus.de (Markus Mauhart) writes:

>I have a problem with "initialisation of references" following
>8.4.3 both in C++PL2 and junes draft of the ansi c++ committee .
>(especially function-call parameters with type "reference")

Yes, ARM 8.4.3 isn't very clear about this.

>  void AA (A&)   ;// not "A const&" !
>  A    f  ()     ;// with 5.2.2 "f()" is no lvalue .

>Is then the following allowed ?

>  void test() {AA(f()) ;}  //initialising "A&" with non-lvalue A.

No.  ARM 13.2:

 "A temporary variable is needed for a formal argument of type T&
 if the actual argument is not an lvalue ... This does not affect
 argument matching.  It may however, affect the legality of the
 resulting match since a temporary may not be used to initialize
 a non-const reference."

This still leaves the legality of
 A& a = f();
in doubt.

Followups to comp.std.c++.

--
Fergus Henderson                     fjh@munta.cs.mu.OZ.AU