Avoid g++ 4.8.2 bug that resulted in infinite loops in the test suite.

g++ 4.8.2, shipped with Ubuntu 14.04, generates incorrect code for checking
the loop termination condition, resulting in never ending loops in
HashMapTest().

Disable the optimizations for this function for 4.8.[012] as the bug seems to
be fixed in 4.8.4 and several similar (but not really identical) bug reports
in gcc bugzilla have been fixed in 4.8.3.

This should allow the unit tests on Linux buildbots, using 4.8.2, to run to
completion again.
This commit is contained in:
Vadim Zeitlin 2015-06-21 01:53:14 +02:00
parent 3195a0e538
commit 052e598d09

View File

@ -376,7 +376,17 @@ void MakeKeyValuePair(size_t i, size_t count, T*& key, ValueT& value)
// the test
template <class HashMapT>
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 && __GLIBC_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;