I just updated (and compiled) clang this afternoon, and a piece of code I had written simply does not work any longer.
It boils down to the following code:
struct Foo {};
void foo(unsigned u) {
std::unordered_map<unsigned, Foo> map;
map.insert(std::make_pair(u, Foo())); // the offending line, also occurs with a std::map
}
And I got a huge backtrace… eurk.
I managed to reduce the test case to:
#include // 1
template
struct Node {
V value;
template <typename… Args>
Node(Args&&… args): value(std::forward(args)…) {} // 8
};
void foo(std::pair<int const, int> const& p) {
Node<std::pair<int const, int>> node(p); // 12
}
Where is picked up from the MinGW implementation of gcc 4.5.2. I get this error:
unordered_map.cpp:8:25: error: call to deleted constructor of ‘std::pair<const int, int>’
Node(Args&&… args): value(std::forward(args)…) {}
^ ~~~~~~~~~~~~~~~~~~~~~~~~
unordered_map.cpp:12:35: note: in instantiation of function template specialization ‘Node<std::pair<const int, int> >::Node<const std::pair<const int, int> &>’ requested here
Node<std::pair<int const, int>> node(p);
^
/mingw/lib/gcc/mingw32/4.5.2/include/c++\bits/stl_pair.h:71:12: note: function has been explicitly marked deleted here
struct pair
^
1 error generated.
The full invocation (with the version of clang) and the preprocessed file can be found in attachment, for those interested.
I was wondering if this is a bug in the gcc 4.5.2 standard library or a bug in clang… and I’d really appreciate a work-around if anyone has one, since I’m pretty much stuck at this point.
– Matthieu
invocation.txt (6.56 KB)
unordered_map.i (37.5 KB)