This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/30925] c++ frontend error: ?-operator parameter binding
- From: "bangerth at dealii dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 9 Mar 2007 04:34:34 -0000
- Subject: [Bug c++/30925] c++ frontend error: ?-operator parameter binding
- References: <bug-30925-14144@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #3 from bangerth at dealii dot org 2007-03-09 04:34 -------
(In reply to comment #0)
Take a look at this again:
> struct A
> {
> operator short& () { return m_value; }
> operator short () const { return m_value; }
> };
>
> const A CONSTA(-1);
>
> struct M {
> void set(A& value) const {
> value = 1 ? m_a : CONSTA;
> }
Since we are in M::set() const, this is a const pointer and m_a is of
type 'const short &'. On the other hand, CONSTA is of type 'const A'. So
the compiler tries to convert CONSTA to 'const short &), but there is no
member function that can do that (both of the conversion operators are
non-const and therefore can't be called; this is what the compiler complains
about).
If I understand you correctly, then the compiler should try to convert the
other way around, i.e. try to convert the 'const short &' to 'const A'. This,
however, is not possible because you declared the conversion constructor
as 'explicit'.
I believe the code is invalid, therefore.
W.
--
bangerth at dealii dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |bangerth at dealii dot org
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30925