Potential bug ?

Theodore Papadopoulo Theodore.Papadopoulo@sophia.inria.fr
Tue May 29 10:37:00 GMT 2001


Before submitting a full bug report, I would like to have some 
feedback. I believe the code is correct, but I may be wrong.
This is related to the message:

http://gcc.gnu.org/ml/gcc/2001-05/msg00192.html

The code is the following:

#include <vector>

typedef std::vector<int> vi;

struct C: public std::vector<vi::iterator> {
    typedef std::vector<vi::iterator> base;
    typedef base::iterator       iterator;
    typedef base::const_iterator const_iterator;
    const_iterator begin()       { return std::vector<vi::iterator>::begin(); }
    const_iterator begin() const { return std::vector<vi::iterator>::begin(); }
};

struct M {
    void begin(const C::iterator& it)             { }
    void begin(const C::const_iterator& it) const { }
};

int
main(int argc,char* argv[])
{
    M m;

    C::const_iterator i=C().begin();
    m.begin(i);
}

With recent g++-3.x snapshots, I get:
vanuatu->g++ Bug.C | & more
Bug.C: In function `int main(int, char**)':
Bug.C:28: choosing `void M::begin(const std::__normal_iterator<const 
   std::__normal_iterator<int*, std::vector<int, std::allocator<int> > >*, 
   std::vector<std::__normal_iterator<int*, std::vector<int, 
   std::allocator<int> > >, std::allocator<std::__normal_iterator<int*, 
   std::vector<int, std::allocator<int> > > > > >&) const' over `void 
   M::begin(const std::__normal_iterator<std::__normal_iterator<int*, 
   std::vector<int, std::allocator<int> > >*, 
   std::vector<std::__normal_iterator<int*, std::vector<int, 
   std::allocator<int> > >, std::allocator<std::__normal_iterator<int*, 
   std::vector<int, std::allocator<int> > > > > >&)'
Bug.C:28:   because worst conversion for the former is better than worst 
   conversion for the latter

First I do not understand why g++ considers this call as ambiguous, 
since I effectively pass something of the right type, so no 
conversion should be required.

I know that the extension the message is refering to 
has been "deprecated" on purpose, but I do not see why this code 
should be affected.

Am I missing something ??

Then, and I believe this is definitely a bug, the message looks like 
a warning "choosing xxx over yyy because ..." but acts as an error 
(ie compilation is aborted). I'll file a gnats report with this one, 
but I'd first like to know whether I should report something for the 
first problem either...

 --------------------------------------------------------------------
 Theodore Papadopoulo
 Email: Theodore.Papadopoulo@sophia.inria.fr Tel: (33) 04 92 38 76 01
 --------------------------------------------------------------------



-- 
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.4 (GNU/Linux)
Comment: Exmh version 2.2 06/23/2000

iD8DBQE7E95kIzTj8qrxOU4RAmX1AJ4wVG9znqKm0A0xMh4FlMl7hshi4ACeJ1gX
sDTsQkl50kh/hDeGq00xd+E=
=fxZp
-----END PGP SIGNATURE-----


More information about the Gcc-bugs mailing list