Compilation of <vector> and self-defined 'distance(a,b)' fails
Jim Wilson
wilson@specifixinc.com
Tue Jun 1 01:29:00 GMT 2004
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
More information about the Gcc-bugs
mailing list