This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: Compilation of <vector> and self-defined 'distance(a,b)' fails
- From: Jim Wilson <wilson at specifixinc dot com>
- To: Benjamin King <king dot benjamin at mh-hannover dot de>
- Cc: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 31 May 2004 18:29:13 -0700
- Subject: Re: Compilation of <vector> and self-defined 'distance(a,b)' fails
- References: <opr8jrhuylwdd902@mail.mh-hannover.de>
Benjamin King wrote:
I think my gcc has a bug. It fails to compile the following program.
Renaming 'distance' to anything else solves this, so I guess that the
'distance' function from <iterator> somehow escaped the std::-namespace.
Filing bug reports into our bugzilla bug tracking database is better
than sending mail to gcc-bugs, as we don't track bug reports mailed to
the list. The result is that you are more likely to get a useful
response if you use bugzilla. See
http://gcc.gnu.org/bugs.html
for more info on reporting bugs.
I am not a C++ expert, so I am really not the right person to be looking
at this. However, I suspect the problem is that the vector class is
itself defined in namespace std, and uses the iterator classes, and that
is somehow causing the search for the distance function to also look at
the interator classes. It isn't just the name distance, any name in
stl_interator.h seems to cause the same problem.
I can get your testcase to compile if I change
d = distance(v, v);
to
d = ::distance(v, v);
--
Jim Wilson, GNU Tools Support, http://www.SpecifixInc.com