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]

[Bug c++/15910] New: can't compile self defined void distance(std::vector<T>, std::vector<T>)


The following program does not compile:

-----
#include <vector>
 
double distance(const std::vector<double> & v1, const std::vector<double> & v2) 
{
  return 0;
}
 
int main(int argc, char* argv[])
{
  std::vector<double> v;
  double d;
  d = distance(v, v);
  return 0;
}
----

In response to a post to gcc-bugs@gcc.gnu.org, Jim Wilson wrote:

----
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);
----

-- 
           Summary: can't compile self defined void distance(std::vector<T>,
                    std::vector<T>)
           Product: gcc
           Version: 3.3.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: king dot benjamin at mh-hannover dot de
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: 3.3.2
  GCC host triplet: 3.3.2
GCC target triplet: 3.3.2


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15910


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