------- 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

Reply via email to