Boost logo

Boost Users :

Subject: Re: [Boost-users] [Format] Asserts with non-default structure packingin 1.37 (MSVC)
From: John Maddock (john_at_[hidden])
Date: 2008-12-30 07:46:19


Daniel James wrote:
>> I'm using MS Visual Studio 2005 to work on some legacy code that has
>> its origins back in 16-bit Windows, and relies on the /Zp2 switch to
>> align fields in structures in the same way as earlier versions.
>>
>> One of the more recent modules uses boost::format, and this has
>> compiled correctly and been working with Boost 1.34.1. I'm trying to
>> bring the project up-to-date using 1.37, and I am getting
>> BOOST_STATIC_ASSERT reports when I include boost/format.hpp.
>>
>> I don't have to *use* format in my code, just including
>> boost/format.hpp in a "Hello world" program is sufficient to trigger
>> the error when using /Zp2
>>
>> Is this to be expected?
>>
>> Is there a workaround?

It appears to be a bug in MSVC's __alignof builtin operator, if you comment
out the line:

# define BOOST_ALIGNMENT_OF(T) __alignof(T)

In line 108 of boost/type_traits/intrinsics.hpp then it all works as
expected (I hope!).

The problem is that __alignof(int) reports 4 even when it's actually 2
(because of /Zp2), so it looks as if we'll have to disable use of that
particular intrinsic :-(

HTH, John.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net