boost::variant build crashes Visual C++

Hello,
I have a simple program to test boost::variant. Under Visual C++
2005, configuration Release (/MD), the build fails with C1060 (out of
heap space). The program compiles and runs as expected under Visual
C++ 2005 Debug (/MTd), and under Visual C++ 2008 Express, Release and
Debug.
Below is the code. Any idea what's wrong?
Many Thanks,
Eric
#include <set>
#include <string>
#include <vector>
#include <iostream>
#include <fstream>
#include <map>
#include , std::vector class print_visitor : public boost::static_visitor<> {
std::string m_indent;
public:
print_visitor(const std::string& indent) : m_indent(indent) {}
print_visitor(const print_visitor& p) : m_indent(p.m_indent) {}
void operator()(const bool& i) const {
std::cout << m_indent << "It's an bool: " << i << '\n';
}
void operator()(const std::string& s) const {
std::cout << m_indent << "It's a std::string: " << s << '\n';
}
void operator()(const double& d) const {
std::cout << m_indent << "It's a double: " << d << '\n';
}
void operator()(const long& d) const {
std::cout << m_indent << "It's a long: " << d << '\n';
}
void operator()(const empty_property_tag& e) const {
std::cout << m_indent << "It's an empty_property_tag.\n";
}
void operator()(std::vector

a a wrote:
I have a simple program to test boost::variant. Under Visual C++ 2005, configuration Release (/MD), the build fails with C1060 (out of heap space). The program compiles and runs as expected under Visual C++ 2005 Debug (/MTd), and under Visual C++ 2008 Express, Release and Debug.
Since I don't have VC2005 I can't be sure, but it's possible that you can solve this problem using the "/ZmXXX" compiler switch. You should replace the XXX with a suitable value (try 100, 200 or 500; basically, you should do a binary search for the best value!) Also, you should read the MSDN entry for the "/Zm" switch. If you use the IDE, you should open the project properties and under "C/C++", go to "Command Line" and add the "/Zm200" to the "Additional Options" field. Make sure you have selected the correct build configuration. -yzt -- "Programming is an art that fights back!"

Hi yzt,
Many thanks for getting back to me, your help is much appreciated.
On Thu, Mar 27, 2008 at 11:51 PM, Yaser Zhian Tabasy
a a wrote:
I have a simple program to test boost::variant. Under Visual C++ 2005, configuration Release (/MD), the build fails with C1060 (out of heap space). The program compiles and runs as expected under Visual C++ 2005 Debug (/MTd), and under Visual C++ 2008 Express, Release and Debug.
Since I don't have VC2005 I can't be sure, but it's possible that you can solve this problem using the "/ZmXXX" compiler switch. You should replace the XXX with a suitable value (try 100, 200 or 500; basically, you should do a binary search for the best value!) Also, you should read the MSDN entry for the "/Zm" switch.
I tried switch /ZmXXX with a couple of different values for XXX, this seems to have no effect on the problem and still the VC8 Release build crashes with C1060. The documentation says that /Zm "Determines the amount of memory that the compiler allocates to construct precompiled headers". Can you give a little more detail on how you think that C1060 could be avoided in this case by changing the memory allocation for precompiled headers? The example I provided in the original post is a sole cpp file, I haven't myself created any headers, precompiled or otherwise. The code #includes various headers from STL and boost, are you saying that those #includes are picking up precompiled headers such that the behavior of the build could be influenced by /Zm? Thanks, Eric

a a wrote:
I tried switch /ZmXXX with a couple of different values for XXX, this seems to have no effect on the problem and still the VC8 Release build crashes with C1060.
The documentation says that /Zm "Determines the amount of memory that the compiler allocates to construct precompiled headers". Can you give a little more detail on how you think that C1060 could be avoided in this case by changing the memory allocation for precompiled headers?
The example I provided in the original post is a sole cpp file, I haven't myself created any headers, precompiled or otherwise. The code #includes various headers from STL and boost, are you saying that those #includes are picking up precompiled headers such that the behavior of the build could be influenced by /Zm?
I'm sorry. It seems that I've been too quick to assume you used precompiled headers or that "/Zm" actually does something other than setting the limit for PCH files. If it was me, I would play with the compiler optimization flags to see which one was the culprit, but I'm sure you've already done than and/or you probably need those optimizations. Also, the MSDN page for the C1060 error code lists some workarounds. They don't seem like breakthroughs or anything, but the file splitting might work (if that's indeed possible to any useful extent with this simple example.) -yzt -- "Programming is an art that fights back!"

On Fri, Mar 28, 2008 at 10:45 PM, Yaser Zhian Tabasy
a a wrote:
I tried switch /ZmXXX with a couple of different values for XXX, this seems to have no effect on the problem and still the VC8 Release build crashes with C1060.
The documentation says that /Zm "Determines the amount of memory that the compiler allocates to construct precompiled headers". Can you give a little more detail on how you think that C1060 could be avoided in this case by changing the memory allocation for precompiled headers?
The example I provided in the original post is a sole cpp file, I haven't myself created any headers, precompiled or otherwise. The code #includes various headers from STL and boost, are you saying that those #includes are picking up precompiled headers such that the behavior of the build could be influenced by /Zm?
I'm sorry. It seems that I've been too quick to assume you used precompiled headers or that "/Zm" actually does something other than setting the limit for PCH files.
If it was me, I would play with the compiler optimization flags to see which one was the culprit, but I'm sure you've already done than and/or you probably need those optimizations. Also, the MSDN page for the C1060 error code lists some workarounds. They don't seem like breakthroughs or anything, but the file splitting might work (if that's indeed possible to any useful extent with this simple example.)
No problem! I appreciate the ideas. I have tried a few tweaks with no success, but I will continue to experiment and I'll post back if I find a solution. Thanks again for your help. Regards, Eric

a a
Hello,
I have a simple program to test boost::variant. Under Visual C++ 2005, configuration Release (/MD), the build fails with C1060 (out of heap space). The program compiles and runs as expected under Visual C++ 2005 Debug (/MTd), and under Visual C++ 2008 Express, Release and Debug.
I tried compiling your example on VC8SP1, with the result being that the compiler (cl.exe) swallowed up almost 2 gigabytes of virtual memory and then fell over with the error you mention. The same code on VC9 builds quickly with no problems. Not a great deal of help i'm afraid - looks like the compiler is getting stuck in a loop or something?

On Fri, Mar 28, 2008 at 3:06 PM, Richard Webb
a a
writes: Hello,
I have a simple program to test boost::variant. Under Visual C++ 2005, configuration Release (/MD), the build fails with C1060 (out of heap space). The program compiles and runs as expected under Visual C++ 2005 Debug (/MTd), and under Visual C++ 2008 Express, Release and Debug.
I tried compiling your example on VC8SP1, with the result being that the compiler (cl.exe) swallowed up almost 2 gigabytes of virtual memory and then fell over with the error you mention. The same code on VC9 builds quickly with no problems. Not a great deal of help i'm afraid - looks like the compiler is getting stuck in a loop or something?
Your feedback is very helpful at least as a sanity test of my results! As mentioned in another post I have tried and so far failed to tweak the Release build into a usable state. We have identified some less complicated variations on our make_recursive_variant typedef which seem OK. Unfortunately this complicates other areas of our app but for now that's our best workaround. Many thanks for your help. Regards, Eric
participants (3)
-
a a
-
Richard Webb
-
Yaser Zhian Tabasy