diff --git a/flang/include/flang/Evaluate/integer.h b/flang/include/flang/Evaluate/integer.h index fccc2ad774a8f..5953fc81cb111 100644 --- a/flang/include/flang/Evaluate/integer.h +++ b/flang/include/flang/Evaluate/integer.h @@ -74,6 +74,7 @@ class Integer { static_assert(std::is_unsigned_v); static_assert(CHAR_BIT * sizeof(BigPart) >= 2 * partBits); static constexpr bool littleEndian{IS_LITTLE_ENDIAN}; + static constexpr int alignment{ALIGNMENT}; private: static constexpr int maxPartBits{CHAR_BIT * sizeof(Part)}; diff --git a/flang/include/flang/Evaluate/real.h b/flang/include/flang/Evaluate/real.h index 03294881850a1..76d25d9fe2670 100644 --- a/flang/include/flang/Evaluate/real.h +++ b/flang/include/flang/Evaluate/real.h @@ -490,7 +490,10 @@ template class Real { bool isNegative, int exponent, const Fraction &, Rounding, RoundingBits, bool multiply = false); - Word word_{}; // an Integer<> + // Require alignment, in case code generation on x86_64 decides that our + // Real object is suitable for SSE2 instructions and then gets surprised + // by unaligned address. + alignas(Word::alignment / 8) Word word_{}; // an Integer<> }; extern template class Real, 11>; // IEEE half format