diff --git a/tests/hashes/hashes.cpp b/tests/hashes/hashes.cpp index 1894b40459..d1d5d4d59e 100644 --- a/tests/hashes/hashes.cpp +++ b/tests/hashes/hashes.cpp @@ -377,7 +377,17 @@ void MakeKeyValuePair(size_t i, size_t count, T*& key, ValueT& value) // the test template -void HashMapTest() +void +#ifdef __GNUC__ +// At least g++ 4.8.2 (included in Ubuntu 14.04) is known to miscompile the +// code in this function and make all the loops below infinite when using -O2, +// so we need to turn off optimizations for it to allow the tests to run at +// all. +#if __GNUC__ == 4 && __GNUC_MINOR__ == 8 && __GNUC_PATCHLEVEL__ < 3 +__attribute__((optimize("O0"))) +#endif // g++ 4.8.[012] +#endif // g++ +HashMapTest() { typedef typename HashMapT::value_type::second_type value_type; typedef typename HashMapT::key_type key_type;