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]
Other format: [Raw text]

Re: Compilation of <vector> and self-defined 'distance(a,b)' fails


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


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