#9619 closed Bugs (invalid)
Deserialization of deep object tree fails on VS2012 when a templated function is called in the same cpp file
Reported by: | Owned by: | Robert Ramey | |
---|---|---|---|
Milestone: | To Be Determined | Component: | serialization |
Version: | Boost 1.55.0 | Severity: | Problem |
Keywords: | Cc: |
Description
When using Visual Studio 2012, error C2996 ("recursive function template definition") is reported by the compiler when all of the following conditions apply:
- A C++ object is deserialized using Boost Serialization somewhere in the *.cpp file.
- 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).
- Somewhere in the same *.cpp file (not necessarily in the same function), some templated function is called.
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.
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.
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.
Note: about to attach a cpp file which reproduces the problem.
Attachments (1)
Change History (5)
by , 9 years ago
Attachment: | BugC2996.cpp added |
---|
comment:1 by , 9 years ago
follow-up: 4 comment:2 by , 9 years ago
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.
comment:3 by , 9 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
comment:4 by , 9 years ago
Replying to ramey:
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.
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.
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?
Code to reproduce the problem