Boost C++ Libraries: Ticket #2409: boost::optional (boost-1.36.0) fails to compile on MSVS 9.0 with struct member alignment being set to 1 byte https://svn.boost.org/trac10/ticket/2409 <p> 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: </p> <pre class="wiki">#include &lt;boost/optional.hpp&gt; boost::optional&lt;int&gt; test_func(int i) { if(i) return boost::optional&lt;int&gt;(1234); else return boost::optional&lt;int&gt;(); } int main(int argc, char* argv[]) { test_func(1); return 0; } </pre><p> The errors are: </p> <pre class="wiki">d:\users\slava\etap\external\boost\boost\type_traits\type_with_alignment.hpp(206) : error C2027: use of undefined type 'boost::STATIC_ASSERTION_FAILURE&lt;x&gt;' 1&gt; with 1&gt; [ 1&gt; x=false 1&gt; ] 1&gt; 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&lt;Align&gt;' being compiled 1&gt; with 1&gt; [ 1&gt; Align=4 1&gt; ] 1&gt; d:\users\slava\etap\external\boost\boost\optional\optional.hpp(112) : see reference to class template instantiation 'boost::type_with_alignment&lt;Align&gt;' being compiled 1&gt; with 1&gt; [ 1&gt; Align=4 1&gt; ] 1&gt; d:\users\slava\etap\external\boost\boost\optional\optional.hpp(113) : see reference to class template instantiation 'boost::optional_detail::aligned_storage&lt;T&gt;::dummy_u' being compiled 1&gt; with 1&gt; [ 1&gt; T=int 1&gt; ] 1&gt; d:\users\slava\etap\external\boost\boost\optional\optional.hpp(448) : see reference to class template instantiation 'boost::optional_detail::aligned_storage&lt;T&gt;' being compiled 1&gt; with 1&gt; [ 1&gt; T=int 1&gt; ] 1&gt; d:\users\slava\etap\external\boost\boost\optional\optional.hpp(455) : see reference to class template instantiation 'boost::optional_detail::optional_base&lt;T&gt;' being compiled 1&gt; with 1&gt; [ 1&gt; T=int 1&gt; ] 1&gt; d:\users\slava\test\test.cpp(8) : see reference to class template instantiation 'boost::optional&lt;T&gt;' being compiled 1&gt; with 1&gt; [ 1&gt; T=int 1&gt; ] 1&gt;d:\users\slava\etap\external\boost\boost\type_traits\type_with_alignment.hpp(207) : error C2027: use of undefined type 'boost::STATIC_ASSERTION_FAILURE&lt;x&gt;' 1&gt; with 1&gt; [ 1&gt; x=false 1&gt; ] </pre><p> 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. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/2409 Trac 1.4.3 rvalde@… Thu, 09 Dec 2010 15:48:29 GMT <link>https://svn.boost.org/trac10/ticket/2409#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2409#comment:1</guid> <description> <p> 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. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Katie Chan</dc:creator> <pubDate>Thu, 09 Dec 2010 15:52:18 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/2409#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2409#comment:2</guid> <description> <p> Reproduced with VC9 &amp; Boost 1.36. But not reproducible with 1.45. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Marshall Clow</dc:creator> <pubDate>Sat, 11 Dec 2010 16:39:54 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/2409#comment:3 https://svn.boost.org/trac10/ticket/2409#comment:3 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> Since this is no longer a problem with recent builds of Boost, I am closing this ticket. </p> <p> If it shows up again, then we can revisit it. </p> Ticket