LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 16542 - ambiguous __construct_node while using tuple as a key for a map
Summary: ambiguous __construct_node while using tuple as a key for a map
Status: RESOLVED FIXED
Alias: None
Product: libc++
Classification: Unclassified
Component: All Bugs (show other bugs)
Version: unspecified
Hardware: PC Linux
: P normal
Assignee: Howard Hinnant
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-07-04 12:53 PDT by Sandipan Mohanty
Modified: 2013-07-04 15:59 PDT (History)
1 user (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sandipan Mohanty 2013-07-04 12:53:01 PDT
The following code compiles and behaves as expected using g++ as well as clang++ with libstdc++. But clang++ with libc++ produces errors. Here is the test code:

#include <map>
#include <tuple>
using namespace std;
int main()
{
    map<tuple<int,int>, size_t> m;
    m[make_tuple<int,int>(2,3)]=7;
}

The error remained the same under clang versions 3.3 (Revision: 185618) and 3.4 (Revision: 185530). Below, I quote the full error message.
--------------------------------------
In file included from maptest.cc:1:
/home/sandipan/local/llvm/3.3/include/c++/v1/map:1295:29: error: call to member function '__construct_node' is ambiguous
        __node_holder __h = __construct_node(_VSTD::move(__k));
                            ^~~~~~~~~~~~~~~~
maptest.cc:7:6: note: in instantiation of member function 'std::__1::map<std::__1::tuple<int, int>, unsigned long, std::__1::less<std::__1::tuple<int, int> >, std::__1::allocator<std::__1::pair<const std::__1::tuple<int, int>,
      unsigned long> > >::operator[]' requested here
    m[make_tuple<int,int>(2,3)]=7;
     ^
/home/sandipan/local/llvm/3.3/include/c++/v1/map:994:10: note: candidate function [with _A0 = std::__1::tuple<int, int>]
         __construct_node(_A0&& __a0);
         ^
/home/sandipan/local/llvm/3.3/include/c++/v1/map:1001:10: note: candidate function [with _A0 = std::__1::tuple<int, int>]
         __construct_node(_A0&& __a0);
         ^
/home/sandipan/local/llvm/3.3/include/c++/v1/map:1004:23: note: candidate function template not viable: requires at least 2 arguments, but 1 was provided
        __node_holder __construct_node(_A0&& __a0, _A1&& __a1, _Args&& ...__args);
                      ^
/home/sandipan/local/llvm/3.3/include/c++/v1/map:987:19: note: candidate function not viable: requires 0 arguments, but 1 was provided
    __node_holder __construct_node();
                  ^
1 error generated.
--------------------------

I haven't examined the code very carefully, but it seems there are two declarations as well as definitions of a function with the (effective) signature: 

__node_holder __construct_node(_A0 &&);
Comment 1 Howard Hinnant 2013-07-04 15:59:32 PDT
Fix Committed revision 185666.