Work around xlC 13.1.4 compiler bugs. (#115)
Addresses in part issue #113. * Make compatibility wrappers/functions that dance around xlC bugs. Wrappers are provied in `util/compat.hpp` and live in the `compat` namespace. - `compat::end` reimplements `std::end` but in a way that apparently does not trigger the xlC bug. - `compat::compiler_barrier_if_xlc_leq()` inserts a compiler reordering barrier if the compiler is xlC and the version less than or equal to that specified. Name is deliberately verbose. - `compat::isinf()` is an inline wrapper around `std::isinf()`, which apparently is sufficient to defuse an evaluation order bug with `std::isinf()` in switch statements. * Use `compat::compiler_barrier_if_xlc_leq()` in `util::unitialized` reference access methods to avoid improper reordering with -O2. * Use `compat::isinf()` in `test_math.cpp` to defuse improper reordering within `EXPECT_EQ` gtest macro of `std::isinf()`. * Use `compat::end()` in `util::back()` and `util::cend()` to avoid incorrect `std::end()` behaviour with -O2. * Use `util::cend()` in `algorithms::sum()`, again to avoid incorrect `std::end()` behaviour with -O2.
Showing
- src/algorithms.hpp 1 addition, 1 deletionsrc/algorithms.hpp
- src/util/compat.hpp 37 additions, 0 deletionssrc/util/compat.hpp
- src/util/iterutil.hpp 3 additions, 1 deletionsrc/util/iterutil.hpp
- src/util/meta.hpp 5 additions, 2 deletionssrc/util/meta.hpp
- src/util/uninitialized.hpp 13 additions, 2 deletionssrc/util/uninitialized.hpp
- tests/unit/test_math.cpp 8 additions, 3 deletionstests/unit/test_math.cpp
src/util/compat.hpp
0 → 100644
Please register or sign in to comment