On Linux x86_64
g++ --version:
g++ (Debian 20100117-1) 4.5.0 20100117 (experimental) [trunk revision 155979]

Compiling with:
g++ -O2 -g -std=c++0x -c test.cpp

The following program:

#include <vector>
#include <map>
struct Foo {
    Foo() {}

    template<typename Tp>
    Foo(Tp *p) {}
};

void foo() {
    std::map <int, std::vector<Foo>> the_map;

    the_map[1] = std::vector<Foo>();
}

Produces the below error. However, it *doesn't* produce an error if compiled
without the -g switch (nor with -O1 instead of -O2).


In file included from /usr/include/c++/4.5.0/bits/move.h:38:0,
                 from /usr/include/c++/4.5.0/bits/stl_pair.h:60,
                 from /usr/include/c++/4.5.0/bits/stl_algobase.h:66,
                 from /usr/include/c++/4.5.0/vector:61,
                 from test.cpp:1:
/usr/include/c++/4.5.0/type_traits: In constructor 'std::vector<_Tp,
_Alloc>::vector(std::vector::size_type, const value_type&, const
allocator_type&) [with _Tp = Foo, _Alloc = std::allocator<Foo>,
std::vector::size_type = long unsigned int, value_type = Foo, allocator_type =
std::allocator<Foo>]':
/usr/include/c++/4.5.0/type_traits:224:67:   instantiated from 'const bool
std::__is_constructible_helper<std::vector<Foo>, const int&&>::__value'
/usr/include/c++/4.5.0/type_traits:235:5:   instantiated from
'std::is_constructible<std::vector<Foo>, const int&&>'
/usr/include/c++/4.5.0/bits/stl_map.h:451:11:   instantiated from here
/usr/include/c++/4.5.0/type_traits:224:67: error: call of overloaded
'allocator()' is ambiguous
/usr/include/c++/4.5.0/bits/allocator.h:103:7: note: candidates are:
std::allocator<_Tp>::allocator(const std::allocator<_Tp>&) [with _Tp = Foo,
std::allocator<_Tp> = std::allocator<Foo>]
/usr/include/c++/4.5.0/bits/allocator.h:101:7: note:                
std::allocator<_Tp>::allocator() [with _Tp = Foo]
/usr/include/c++/4.5.0/type_traits:224:67: error: call of overloaded
'allocator()' is ambiguous
/usr/include/c++/4.5.0/bits/allocator.h:103:7: note: candidates are:
std::allocator<_Tp>::allocator(const std::allocator<_Tp>&) [with _Tp = Foo,
std::allocator<_Tp> = std::allocator<Foo>]
/usr/include/c++/4.5.0/bits/allocator.h:101:7: note:                
std::allocator<_Tp>::allocator() [with _Tp = Foo]
/usr/include/c++/4.5.0/type_traits:218:2: error: call of overloaded
'allocator()' is ambiguous
/usr/include/c++/4.5.0/bits/allocator.h:103:7: note: candidates are:
std::allocator<_Tp>::allocator(const std::allocator<_Tp>&) [with _Tp = Foo,
std::allocator<_Tp> = std::allocator<Foo>]
/usr/include/c++/4.5.0/bits/allocator.h:101:7: note:                
std::allocator<_Tp>::allocator() [with _Tp = Foo]


-- 
           Summary: call of overloaded 'allocator()' is ambiguous
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: foom at fuhm dot net


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

Reply via email to