This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: c++/9440: [3.4 regression] error message about non-lvalue


As far as I can see, this is what happens:

The compiler creates temporaries for args 2 and 3 of the conditional
operator (i.e. A() and a in Andrew's example) by calling A(const A&).
The parameter to the copy constructor is calculated by build_this()
in cp/call.c. This function, however, only knows one way to calculate
the this pointer: it uses ADDR_EXPR, which does not work for non-
lvalues - hence the error message concerning "unary &".
This problem did not occur prior to the patch cited by Craig, because
the compiler would simply neglect to build temporaries for non-lvalues
occurring as arguments to the conditional operator.

I think the best way to fix PR 9440 (and probably 9537) is to fix
build_this(), i.e. crawl along the tree (at least for non-lvalues)
to find /this/ rather than blindly use ADDR_EXPR.

I can try to implement this, but my knowledge about the internals
of cc1plus is rather scarce, so if you a quick solution is needed,
someone else might want to step forward.

Ansgar

-- 
Institut fuer theoretische Physik II    | Geb. 25.32.02
Heinrich-Heine-Universitaet Duesseldorf | +49-211-8112059 (phone)
Universitaetsstr. 1                     | +49-211-8112262 (fax)
D-40225 Duesseldorf, Germany            | 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]