[Bug c++/23213] New: Error in Koenig Lookup causes overload resolution failure

adah at netstd dot com gcc-bugzilla@gcc.gnu.org
Wed Aug 3 06:59:00 GMT 2005


http://groups-beta.google.com/group/comp.lang.c++.moderated/browse_thread/thread/3c449572456c8592

The test program:

#include <vector>
int distance(std::vector<int> v1, std::vector<int> v2)
{
    return v1.size() - v2.size();
}
int main()
{
    std::vector<int> v1(3), v2(1);
    int d = distance(v1, v2);
    return 0;
}

The error message from 3.4.4:

D:/mingw-gcc3.4/bin/../lib/gcc/mingw32/3.4.4/../../../../include/c++/3.4.4/bits/stl_iterator_base_types.h:
In instantiation of `std::iterator_traits<std::vector<int, std::allocator<int> > >':
test1.cpp:11:   instantiated from here
D:/mingw-gcc3.4/bin/../lib/gcc/mingw32/3.4.4/../../../../include/c++/3.4.4/bits/stl_iterator_base_types.h:129:
error: no type named `iterator_category' in `class std::vector<int,
std::allocator<int> >'

It has been confirmed that the problem is not that Koenig lookup takes priority
over the local overload, etc.  It is that the failure to deduce the return type
of the instantiation of std::distance<>() caused the abortion of candidate
building.  If the necessary typedef is provided, the local version of distance
will be correctly selected.

It might be arguable whether SFINAE should be applied here (the C++ standard is
not quite clear on this).  But I do not think it the purpose of the standard to
let something in the std namespace affect local name resolution.  Maybe you
gurus here can judge better?

This problem occurs from 2.95.3 to 3.4.4.  I believe it is platform-independent.

-- 
           Summary: Error in Koenig Lookup causes overload resolution
                    failure
           Product: gcc
           Version: 3.4.4
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: adah at netstd dot com
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i386-pc-mingw32
  GCC host triplet: i386-pc-mingw32
GCC target triplet: i386-pc-mingw32


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



More information about the Gcc-bugs mailing list