c++/9440: [3.4 regression] error message about "non-lvalue in unary '&'" when using ?: operator
Andrew Pollard
andrewp@andypo.net
Tue Jan 28 18:26:00 GMT 2003
The following reply was made to PR c++/9440; it has been noted by GNATS.
From: Andrew Pollard <andrewp@andypo.net>
To: bangerth@dealii.org, andrew@andypo.net, gcc-bugs@gcc.gnu.org,
gcc-gnats@gcc.gnu.org
Cc:
Subject: Re: c++/9440: [3.4 regression] error message about "non-lvalue in unary '&'" when using ?: operator
Date: Tue, 28 Jan 2003 18:16:44 GMT
bangerth@dealii.org replied:
> Confirmed. The problem is the lack of a copy constructor,
> but the message is profoundly unhelpful in detecting this.
I don't think a copy constructor should have anything to do with it.
Doesn't the compiler synthesize a copy constructor if there isn't
one defined?
Anyway, even if I add one, I still get the error...
odd.cxx:
--------------
struct A {
explicit A(int = 0);
A(const A&);
operator int() const;
};
A
bar(bool b, const A& a)
{
return (b ? A() : a);
}
--------------
% g++34 -c odd.cxx
odd.cxx: In function `A bar(bool, const A&)':
odd.cxx:10: error: non-lvalue in unary `&'
Andrew.
More information about the Gcc-prs
mailing list