This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/9440] [3.4 regression] error message about "non-lvalue in unary '&'" when using ?: operator
- From: "lpadovan at cs dot unibo dot it" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 13 Nov 2004 17:52:11 -0000
- Subject: [Bug c++/9440] [3.4 regression] error message about "non-lvalue in unary '&'" when using ?: operator
- References: <20030125175600.9440.andrew@andypo.net>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From lpadovan at cs dot unibo dot it 2004-11-13 17:52 -------
I'm experiencing a problem with
g++-3.4 (GCC) 3.4.2 (Debian 3.4.2-3)
which seems related to this bug, at least because the error message is similar
and the operator ?: is involved. Here is the program that shows the problem:
class V;
template <class P>
struct S
{
S(P* p) : ptr(p) { }
operator P*() const { return ptr; }
P* ptr;
};
template <class P>
struct A
{
S<V> f(const S<V>& x) { return (x ? x : (x ? x : 0)); }
};
and the error is:
a.cc: In member function `S<V> A<P>::f(const S<V>&)':
a.cc:14: error: non-lvalue in unary `&'
a.cc:14: error: could not convert `x' to `bool'
In
g++ (GCC) 3.3.5 (Debian 1:3.3.5-2)
the same program is compiled correctly.
Unfortunately I'm unable to test the program with the latest version of the g++
compiler, so please accept my apologies if this has been solved already.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=9440