From ec434c918a9fd01a77e65184e6e1d24aa1e43cfb Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 21 Jun 2015 01:53:14 +0200 Subject: [PATCH] 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. --- tests/hashes/hashes.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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;