http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52942
Bug #: 52942
Summary: [4.7 Regression] using std::ref with a
std::unordered_map fails to compile
Classification: Unclassified
Product: gcc
Version: 4.7.0
Status: UNCONFIRMED
Severity: major
Priority: P3
Component: c++
AssignedTo: [email protected]
ReportedBy: [email protected]
The following C++ I believe to be valid C++1 , but produces error messages (At
bottom).
$g++ -std=c++11 -c foo.cc
#include <functional>
#include <string>
#include <unordered_map>
struct TFoo {};
namespace std {
template <>
struct hash<TFoo> {
size_t operator()(const TFoo &) const {
return 0;
}
};
}
void f1(std::unordered_map<TFoo, int> &) {}
void f2() {
std::unordered_map<TFoo, int> map1;
std::bind(f1, std::ref(map1));
}
In file included from
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/functional:50:0,
from foo.cc:1:
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/functional:
In instantiation of 'constexpr const bool
std::__has_argument_type_helper<std::unordered_map<TFoo, int> >::value':
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/functional:305:1:
required from 'struct std::__has_argument_type<std::unordered_map<TFoo, int>
>'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/functional:316:12:
required from 'struct std::_Reference_wrapper_base<std::unordered_map<TFoo,
int> >'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/functional:432:11:
required from 'class std::reference_wrapper<std::unordered_map<TFoo, int> >'
foo.cc:22:30: required from here
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/stl_function.h:105:21:
error: 'typedef struct std::pair<const TFoo, int>
std::unary_function<std::pair<const TFoo, int>, const TFoo>::argument_type' is
inaccessible
In file included from foo.cc:1:0:
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/functional:305:3:
error: within this context
In file included from
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/functional:50:0,
from foo.cc:1:
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/functional:
In instantiation of 'struct std::_Reference_wrapper_base_impl<true, false,
std::unordered_map<TFoo, int> >':
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/functional:316:12:
required from 'struct std::_Reference_wrapper_base<std::unordered_map<TFoo,
int> >'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/functional:432:11:
required from 'class std::reference_wrapper<std::unordered_map<TFoo, int> >'
foo.cc:22:30: required from here
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/stl_function.h:105:21:
error: 'typedef struct std::pair<const TFoo, int>
std::unary_function<std::pair<const TFoo, int>, const TFoo>::argument_type' is
inaccessible
In file included from foo.cc:1:0:
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/functional:283:43:
error: within this context