Boost C++ Libraries: Ticket #9619: Deserialization of deep object tree fails on VS2012 when a templated function is called in the same cpp file https://svn.boost.org/trac10/ticket/9619 <p> When using Visual Studio 2012, error C2996 ("recursive function template definition") is reported by the compiler when all of the following conditions apply: </p> <ol><li>A C++ object is deserialized using Boost Serialization somewhere in the *.cpp file. </li><li>The serialized object is "deep enough" (~5 levels - i.e. A contains a vector of B, B contains a vector of C, etc. until E). </li><li>Somewhere in the same *.cpp file (not necessarily in the same function), some templated function is called. </li></ol><p> The error is no longer reported if the object is changed to be more "shallow". The error is no longer reported if the call to the templated function is removed. </p> <p> This error does not reproduce in VS2010. It occurs in VS2012 as well as VS2013. Tested with Boost versions 1.49, 1.52, 1.55 - same problem. </p> <p> Note: while this may be caused by an underlying bug in VS2012 (and I have opened an issue with Microsoft Connect regarding this), I think we need a workaround within Boost, as the chances that Microsoft will fix this are slim at best. </p> <p> Note: about to attach a cpp file which reproduces the problem. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/9619 Trac 1.4.3 Yodan Tauber <yodan.tauber@…> Thu, 30 Jan 2014 16:02:19 GMT attachment set https://svn.boost.org/trac10/ticket/9619 https://svn.boost.org/trac10/ticket/9619 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">BugC2996.cpp</span> </li> </ul> <p> Code to reproduce the problem </p> Ticket Yodan Tauber <yodan.tauber@…> Thu, 30 Jan 2014 16:03:10 GMT <link>https://svn.boost.org/trac10/ticket/9619#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/9619#comment:1</guid> <description> <p> Microsoft Connect ticket: <a class="ext-link" href="https://connect.microsoft.com/VisualStudio/feedback/details/816119/error-c2996-reported-on-unrelated-line-when-a-deep-object-tree-is-deserialized-using-boost-serialization"><span class="icon">​</span>https://connect.microsoft.com/VisualStudio/feedback/details/816119/error-c2996-reported-on-unrelated-line-when-a-deep-object-tree-is-deserialized-using-boost-serialization</a> </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Robert Ramey</dc:creator> <pubDate>Thu, 30 Jan 2014 19:53:56 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/9619#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/9619#comment:2</guid> <description> <p> Typically something like this occurs when templates are nested "too deep". Try using the compiler switch to increase template depth to 256 levels. I forget what the template switch name is - you'll have to look it up. You can also look a the bjam files for tests and build. Respond here if the problem can be fixed this way. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Robert Ramey</dc:creator> <pubDate>Fri, 31 Jan 2014 18:37:50 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/9619#comment:3 https://svn.boost.org/trac10/ticket/9619#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">invalid</span> </li> </ul> Ticket Yodan Tauber <yodan.tauber@…> Sun, 02 Feb 2014 08:52:18 GMT <link>https://svn.boost.org/trac10/ticket/9619#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/9619#comment:4</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/9619#comment:2" title="Comment 2">ramey</a>: </p> <blockquote class="citation"> <p> Typically something like this occurs when templates are nested "too deep". Try using the compiler switch to increase template depth to 256 levels. I forget what the template switch name is - you'll have to look it up. You can also look a the bjam files for tests and build. Respond here if the problem can be fixed this way. </p> </blockquote> <p> Unfortunately there is no such switch in MSVC. As far as I can understand, bjam's "c++-template-depth" argument is not used when building with MSVC. </p> <p> Anyway, how is it that an object tree just 5 levels deep is deep enough to hit the compiler limit when Boost serialization is used? </p> </description> <category>Ticket</category> </item> </channel> </rss>