[Bug c++/30925] c++ frontend error: ?-operator parameter binding

2007-03-08 Thread bangerth at dealii 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



[Bug c++/30925] c++ frontend error: ?-operator parameter binding

2007-02-26 Thread istvan at benedek-home dot de


--- Comment #2 from istvan at benedek-home dot de  2007-02-26 14:52 ---
>?: is a lvalue in C++
Why? I'm missing the quotation from the Holy Standard!

IMHO:
we deal with two nonmodifiable lvalues here.

from HS 5.12 3:
Because E1 can't be converted to type 'reference to T2', the Section 'Otherwise
hits us:
'... E1 can be converted to match E2 if E1 can be implicitly converted to the
type that E2 would have if E2 were converted to an rvalue ...'

Please reconsider your opinion. 


-- 

istvan at benedek-home dot de changed:

   What|Removed |Added

 Status|RESOLVED|UNCONFIRMED
 Resolution|INVALID |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30925



[Bug c++/30925] c++ frontend error: ?-operator parameter binding

2007-02-22 Thread pinskia at gcc dot gnu dot org


--- Comment #1 from pinskia at gcc dot gnu dot org  2007-02-22 23:37 ---
Hmm, ?: is a lvalue in C++. Since m_a is still an lvalue (a non modifiable one
though) we try to use "operator short&" so we get the same type, const short&,
on both sides of the ":" as short& is a closer match to const short& as for
short you have to bind a rvalue to a lvalue which is a longer way around.  So
is not a bug in GCC.

If you want this to work, change "operator short" to "operator const short&"
and it will just work.


-- 

pinskia at gcc dot gnu dot org changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution||INVALID


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30925