Boost C++ Libraries: Ticket #13108: BOOST_STATIC_ASSERT occurs when serializing a class with default constructor explicitly defined https://svn.boost.org/trac10/ticket/13108 <p> the following code gives an error: </p> <pre class="wiki">struct myStruct_assert{ myStruct_assert(){} int objectId; }; BOOST_STATIC_ASSERT( boost::serialization::detail::is_default_constructible&lt; myStruct_assert &gt;::value ); </pre><p> error C2027: use of undefined type 'boost::STATIC_ASSERTION_FAILURE&lt;x&gt; with [ x=false ]' </p> <p> while the following code produces no error </p> <pre class="wiki">struct myStruct_noassert{ int objectId; }; BOOST_STATIC_ASSERT( boost::serialization::detail::is_default_constructible&lt; myStruct_noassert &gt;::value ); </pre><p> Also, in case of </p> <pre class="wiki">boost::optional&lt; int &gt; objectId; </pre><p> the error is produced in both cases - with or without default constructor specified </p> <p> boost libraries are compiled with following parameters: </p> <pre class="wiki"> toolset=msvc-9.0 variant=debug threading=multi link=shared/static BOOST_USE_WINAPI_VERSION=0x0501 _BIND_​TO_CURRENT_VCLIBS_VERSION BOOST_ALL_DYN_LINK BOOST_OPTIONAL_USE_OLD_DEFINITION_OF_NONE BOOST_OPTIONAL_CONFIG_USE_OLD_IMPLEMENTATION_OF_OPTIONAL </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/13108 Trac 1.4.3 anonymous Thu, 06 Jul 2017 09:03:31 GMT version changed https://svn.boost.org/trac10/ticket/13108#comment:1 https://svn.boost.org/trac10/ticket/13108#comment:1 <ul> <li><strong>version</strong> <span class="trac-field-old">Boost 1.63.0</span> → <span class="trac-field-new">Boost 1.64.0</span> </li> </ul> Ticket Richard Hazlewood <boost@…> Wed, 12 Jul 2017 19:17:16 GMT <link>https://svn.boost.org/trac10/ticket/13108#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/13108#comment:2</guid> <description> <p> Same issue occurs for g++ 4.6.4 (with -std=c++0x). It looks like <code>boost::serialization::detail::is_default_constructible</code> falls into using <code>boost::has_trivial_constructor</code>; however, it may be that this just does not fully work for these compilers (see docs: <a href="http://www.boost.org/doc/libs/1_64_0/libs/type_traits/doc/html/boost_typetraits/reference/has_trivial_constructor.html">http://www.boost.org/doc/libs/1_64_0/libs/type_traits/doc/html/boost_typetraits/reference/has_trivial_constructor.html</a>) </p> <p> Oddly enough the constructor declared with <code>= default</code> passes on g++ 4.6.4; e.g.<br /> ( g++-4.6 -W -Wall -std=c++0x ... ) </p> <pre class="wiki"> #include "boost/serialization/detail/is_default_constructible.hpp" #ifndef BOOST_HAS_TRIVIAL_CONSTRUCTOR #error #endif struct T { T() = default; }; struct X { X() {} }; int main(int argc, char *argv[]) { (void)argc; (void)argv; static_assert(BOOST_HAS_TRIVIAL_CONSTRUCTOR(T), "t fail"); static_assert(BOOST_HAS_TRIVIAL_CONSTRUCTOR(X), "x fail"); } </pre><p> boost_htd.cpp:22:3: error: static assertion failed: "x fail" </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Robert Ramey</dc:creator> <pubDate>Fri, 11 Aug 2017 11:30:33 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/13108#comment:3 https://svn.boost.org/trac10/ticket/13108#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">wontfix</span> </li> </ul> <p> This is just a limitation of older compilers. The explanation can be found at <a class="ext-link" href="https://github.com/boostorg/serialization/blob/develop/include/boost/serialization/detail/is_default_constructible.hpp"><span class="icon">​</span>https://github.com/boostorg/serialization/blob/develop/include/boost/serialization/detail/is_default_constructible.hpp</a> </p> <p> I'm sorry there is just no way to fix it other than not explicitly defining a default constructor which you shouldn't need to do anyway. </p> Ticket