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 in unary '&'" when using ?: operator


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.


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