Opened 14 years ago
Closed 12 years ago
#2409 closed Bugs (fixed)
boost::optional (boost-1.36.0) fails to compile on MSVS 9.0 with struct member alignment being set to 1 byte
Reported by: | Owned by: | Fernando Cacciola | |
---|---|---|---|
Milestone: | Boost 1.37.0 | Component: | optional |
Version: | Boost 1.36.0 | Severity: | Regression |
Keywords: | Cc: |
Description
When I try to compile the following code with MSVS 9.0 and boost-1.36.0 with struct member alignment being set to 1 or 2 bytes, it fails with boost::STATIC_ASSERTION_FAILURE:
#include <boost/optional.hpp> boost::optional<int> test_func(int i) { if(i) return boost::optional<int>(1234); else return boost::optional<int>(); } int main(int argc, char* argv[]) { test_func(1); return 0; }
The errors are:
d:\users\slava\etap\external\boost\boost\type_traits\type_with_alignment.hpp(206) : error C2027: use of undefined type 'boost::STATIC_ASSERTION_FAILURE<x>' 1> with 1> [ 1> x=false 1> ] 1> d:\users\slava\etap\external\boost\boost\type_traits\type_with_alignment.hpp(218) : see reference to class template instantiation 'boost::detail::type_with_alignment_imp<Align>' being compiled 1> with 1> [ 1> Align=4 1> ] 1> d:\users\slava\etap\external\boost\boost\optional\optional.hpp(112) : see reference to class template instantiation 'boost::type_with_alignment<Align>' being compiled 1> with 1> [ 1> Align=4 1> ] 1> d:\users\slava\etap\external\boost\boost\optional\optional.hpp(113) : see reference to class template instantiation 'boost::optional_detail::aligned_storage<T>::dummy_u' being compiled 1> with 1> [ 1> T=int 1> ] 1> d:\users\slava\etap\external\boost\boost\optional\optional.hpp(448) : see reference to class template instantiation 'boost::optional_detail::aligned_storage<T>' being compiled 1> with 1> [ 1> T=int 1> ] 1> d:\users\slava\etap\external\boost\boost\optional\optional.hpp(455) : see reference to class template instantiation 'boost::optional_detail::optional_base<T>' being compiled 1> with 1> [ 1> T=int 1> ] 1> d:\users\slava\test\test.cpp(8) : see reference to class template instantiation 'boost::optional<T>' being compiled 1> with 1> [ 1> T=int 1> ] 1>d:\users\slava\etap\external\boost\boost\type_traits\type_with_alignment.hpp(207) : error C2027: use of undefined type 'boost::STATIC_ASSERTION_FAILURE<x>' 1> with 1> [ 1> x=false 1> ]
Setting struct member alignment to 4 or more bytes solves the problem. The same code compiles well with any alignment value with boost-1.35.
Change History (3)
comment:1 by , 12 years ago
comment:3 by , 12 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Since this is no longer a problem with recent builds of Boost, I am closing this ticket.
If it shows up again, then we can revisit it.
Note:
See TracTickets
for help on using tickets.
I've tested the example in Microsoft Visual Studio 2008 (9) with both /Zp1 and /Zp2 compiler options (1 byte and 2 bytes struct aligment respectively), using boost 1.43 libraries and I don't see any problems, neither release nor debug compilations.