This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: gcc 3.3 operator[] disambiguation
As pointed out by Wolfgang Bangerth in a completely prescient
mental exercise, the offending effect was made of the overloaded
* in addition to [], and the fact that I used an int for index i
where the original was defined as long int. However, all of the
offending code, except for my wongly typed i, was generated by
a legitimate CORBA vendor. This error will arise in any use of
an int index with any typical vector-like wrapper overloading []
and *. I bet there're tons of homebrewn code like this.
I foresee that in the Year of GCC 3.3, many users will spend
hours and days staring at the Amazing Curses of GCC 3.3. :) It's
very easy to slip with an idiom such as, for (int i...), and then
wonder what's going on. I'm a big defender of C++ against Java
and the rise of general stupidity, but this is a poster case why
compilers should be better at pedagogical diagnostics. This is
also the first case where I see ISO C++ rigor misfired.
Phil, this is clearly a step in another direction from the
notanidiot warning, it's an error now! It becomes a warning with
-fpermissive. What is a good notanidiot way to deal with it,
lest changing int to long? :)
Cheers,
Alexy
On Wed, Jun 25, 2003 at 10:13:09AM +0100, Nathan Sidwell wrote:
> Alexy Khrabrov wrote:
> > I switched from gcc 2.95.3 to 3.3 for MICO 2.3.10,
> > a CORBA C++ implementation, and got this most amazing
> > error ever:
> >
> > MS_EntryFactoryImpl.C:101: error: ISO C++ says that `typename T::ElementType
> > TSeqVar<T>::operator[](long unsigned int) [with T =
> > StringSequenceTmpl<CORBA::String_var>]' and `operator[]' are ambiguous even
> > though the worst conversion for the former is better than the worst
> > conversion for the latter
> >
> > The CORBA Var types precede auto_ptr with the same idea.
> > What's funny is there's no parameterless operator[] in their
> > declaration for CORBA Sequence Var template. A CORBA
> > Sequence type is like a vector, and the offending line contains
> > a simple dereference, like seqV[i] so the mere use of it causes
> > a problem! I wonder what is meant there by "and `operator[]'"?
> the builtin operator[]. Do you have a conversion op from TSeqVar<T>
> to a pointer?
>
> nathan
>
>
> --
> Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
> The voices in my head said this was stupid too
> nathan@codesourcery.com :: http://www.planetfall.pwp.blueyonder.co.uk
>