30 Mar
2014
30 Mar
'14
4:22 p.m.
On 30/03/14 08:41, Glen Fernandes wrote:
Very surprising, but easily reproducible with VC12 (2013), Release or Debug configuration, Win32 platform: the following program will often* throw:
#include
#include <cstdint> int main() { boost::aligned_storage<8, 8>::type a; if (((std::uintptr_t)&a % 8) != 0) { throw 1; } } * Four of every five times it failed because the storage was only 4-byte aligned, not 8-byte aligned.
Does not reproduce for x64 builds, just x86 builds. Does not reproduce with alignment values other than 8.
AFAIK, with Windows 32-bit, you cannot reliably have an object with alignment greater than 4 on the stack. Use dynamic memory allocation.