gcc standard library experts out there?

I'm addressing some test failures in the serialization library and need some help from someone who is knowledgable regarding the implementation of the standard library as it is delivered with the GCC compiler. http://tinyurl.com/s4ohn Shows the error message which is provoked by the following test code: // test array of objects BOOST_STD_EXTENSION_NAMESPACE::hash_set<A> ahash_set; ... std::vector<A> tvec, tvec1; std::copy(ahash_set.begin(), ahash_set.end(), std::back_inserter(tvec)); // error starts here std::sort(tvec.begin(), tvec.end()); a) I can't see anything wrong with this. b) No other compilers complain c) I can't follow the error message So if anyone has some insight here, I'd be glad to hear it. Robert Ramey

Robert Ramey wrote:
http://tinyurl.com/s4ohn Shows the error message which is provoked by the following test code:
// test array of objects BOOST_STD_EXTENSION_NAMESPACE::hash_set<A> ahash_set; ... std::vector<A> tvec, tvec1; std::copy(ahash_set.begin(), ahash_set.end(), std::back_inserter(tvec)); // error starts here std::sort(tvec.begin(), tvec.end());
a) I can't see anything wrong with this. b) No other compilers complain c) I can't follow the error message
So if anyone has some insight here, I'd be glad to hear it.
Are you absolutely sure that's the line? The compiler is claiming that it can't call the hashing function with an argument of type A (probably means there's no appropriate overload). The puzzling thing is that it wants to call the hasher because it's resizing the hashtable, and it's doing that in response to a call to hash_set::insert - allegedly directly from your code. I can't track the error beyond this. The standard library in my GCC 3.4.4 is quite different. Sebastian Redl

"Robert Ramey" <ramey@rrsd.com> writes:
I'm addressing some test failures in the serialization library and need some help from someone who is knowledgable regarding the implementation of the standard library as it is delivered with the GCC compiler.
http://tinyurl.com/s4ohn Shows the error message which is provoked by the following test code:
// test array of objects BOOST_STD_EXTENSION_NAMESPACE::hash_set<A> ahash_set; ... std::vector<A> tvec, tvec1; std::copy(ahash_set.begin(), ahash_set.end(), std::back_inserter(tvec)); // error starts here std::sort(tvec.begin(), tvec.end());
a) I can't see anything wrong with this. b) No other compilers complain c) I can't follow the error message
So if anyone has some insight here, I'd be glad to hear it.
I suggest you post the error message. But first pass it through stlfilt (http://www.bdsoft.com) with line wrapping and indenting enabled, and take a look yourself to see if it makes any more sense. -- Dave Abrahams Boost Consulting www.boost-consulting.com

Robert Ramey wrote:
http://tinyurl.com/s4ohn Shows the error message which is provoked by the following test code:
// test array of objects BOOST_STD_EXTENSION_NAMESPACE::hash_set<A> ahash_set; ... std::vector<A> tvec, tvec1; std::copy(ahash_set.begin(), ahash_set.end(), std::back_inserter(tvec)); // error starts here std::sort(tvec.begin(), tvec.end());
a) I can't see anything wrong with this. b) No other compilers complain c) I can't follow the error message
The error message means that there is no hash-function for A. The following example works for GCC 4.0.3, removing the hash<A>-specialization reveals the error you found: #include <vector> #include <ext/hash_set> class A {}; namespace __gnu_cxx { template<> struct hash<A> { size_t operator()( const A& ) const { return 0; } }; } int main() { __gnu_cxx::hash_set<A> ahash_set; std::vector<A> tvec, tvec1; std::copy(ahash_set.begin(), ahash_set.end(), std::back_inserter(tvec)); } HTH, Daniel

Very good. That explains it all to me. Of course any good answer begets another question. The problem only occurs with GCC standard library implementation. At first I thought that other libraries included a default hash function for Free. Now that I think about, I don't know for a fact that any other libraries actually implement the hash_map and hash_set so perhaps its never even been tested. Thanks again Robert Ramey Daniel Frey wrote:
Robert Ramey wrote:
http://tinyurl.com/s4ohn Shows the error message which is provoked by the following test code:
// test array of objects BOOST_STD_EXTENSION_NAMESPACE::hash_set<A> ahash_set; ... std::vector<A> tvec, tvec1; std::copy(ahash_set.begin(), ahash_set.end(), std::back_inserter(tvec)); // error starts here std::sort(tvec.begin(), tvec.end());
a) I can't see anything wrong with this. b) No other compilers complain c) I can't follow the error message
The error message means that there is no hash-function for A. The following example works for GCC 4.0.3, removing the hash<A>-specialization reveals the error you found:
#include <vector> #include <ext/hash_set>
class A {};
namespace __gnu_cxx { template<> struct hash<A> { size_t operator()( const A& ) const { return 0; } }; }
int main() { __gnu_cxx::hash_set<A> ahash_set;
std::vector<A> tvec, tvec1; std::copy(ahash_set.begin(), ahash_set.end(), std::back_inserter(tvec)); }
HTH, Daniel
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

False alarm - I had the hash function but failed to specify conditions for its inclustion - thansk again Robert Ramey Robert Ramey wrote:
Very good. That explains it all to me.
Of course any good answer begets another question. The problem only occurs with GCC standard library implementation. At first I thought that other libraries included a default hash function for Free. Now that I think about, I don't know for a fact that any other libraries actually implement the hash_map and hash_set so perhaps its never even been tested.
Thanks again
Robert Ramey
Daniel Frey wrote:
Robert Ramey wrote:
http://tinyurl.com/s4ohn Shows the error message which is provoked by the following test code:
// test array of objects BOOST_STD_EXTENSION_NAMESPACE::hash_set<A> ahash_set; ... std::vector<A> tvec, tvec1; std::copy(ahash_set.begin(), ahash_set.end(), std::back_inserter(tvec)); // error starts here std::sort(tvec.begin(), tvec.end());
a) I can't see anything wrong with this. b) No other compilers complain c) I can't follow the error message
The error message means that there is no hash-function for A. The following example works for GCC 4.0.3, removing the hash<A>-specialization reveals the error you found:
#include <vector> #include <ext/hash_set>
class A {};
namespace __gnu_cxx { template<> struct hash<A> { size_t operator()( const A& ) const { return 0; } }; }
int main() { __gnu_cxx::hash_set<A> ahash_set;
std::vector<A> tvec, tvec1; std::copy(ahash_set.begin(), ahash_set.end(), std::back_inserter(tvec)); }
HTH, Daniel
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
participants (4)
-
Daniel Frey
-
David Abrahams
-
Robert Ramey
-
Sebastian Redl