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]

Re: C++ conversion rules ???


>>>>> Alexandre Oliva <oliva@dcc.unicamp.br> writes:

 > IMO, requiring the user to change his code, either by adding an
 > explicit cast or an additional conversion operator, just to avoid this
 > warning, is a very bad move.

 >> Jason, can we please disable the warning, or make it conditional on a
 >> flag?

 > I vote for simply disabling it.  Ok to install?

No.  The warning is important; if your class has a conversion op that
converts to a type A, and another op which converts to type B which can
convert to A, you would expect that a cast to A would call the A operator.
But if it's const and the B one isn't, we end up going through the B op.
In the testcase we saw here, the two ops are identical, so there's no
problem, but if we're dealing with base & derived pointers, or a pointer
and bool, we're liable to run into significant problems.

The warning is there because the overload resolution rules are broken.

Jason


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