From 4c1e03ebff97ad41889a2067eedba121bc526c64 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Mon, 10 Apr 2017 22:20:34 +0300 Subject: [PATCH] Fixed alignment issue with GCC/Clang i386 build --- src/dobjtype.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/dobjtype.cpp b/src/dobjtype.cpp index f681def3e..b4fd9835d 100644 --- a/src/dobjtype.cpp +++ b/src/dobjtype.cpp @@ -780,6 +780,15 @@ PFloat::PFloat(unsigned int size) mDescriptiveName.Format("Float%d", size); if (size == 8) { +#ifdef __i386__ + // According to System V i386 ABI alignment of double type is 4 + // GCC and Clang for 32-bit Intel targets follow this requirement + // However GCC has -malign-double option to enable 8-byte alignment + // So calculation of the actual alignment is needed + struct AlignmentCheck { uint8_t i; double d; }; + Align = static_cast(offsetof(AlignmentCheck, d)); +#endif // __i386__ + SetDoubleSymbols(); } else