[function] Internal compiler error on VC 7.1 with default parameter

The following code snippet: #include <boost/function.hpp> class TestClass { public: void doSomethingDefault(boost::function2<void, bool, bool> cb=boost::function2<void,bool,bool>()) {;} }; int main() { TestClass test; test.doSomethingDefault(); return 1; } Gives an internal compiler error on vc 7.1: cl /nologo /Od /Ob0 /Z7 /W1 /MDd /EHsc /GR /TP /Ic:\Software\boost\boost_1_33_1 /DWIN32 /D_WINDOWS /D_DEBUG /c test.cpp /Fotest.obj test.cpp test.cpp(6) : fatal error C1001: INTERNAL COMPILER ERROR (compiler file 'msc1.cpp', line 2701) Please choose the Technical Support command on the Visual C++ Help menu, or open the Technical Support help file for more information scons: *** [test.obj] Error 2 scons: building terminated because of errors. (line 6 is the method declaration with the default value). If I remove the use of the default value, the code compiles with no errors. I know this code compiles and works correctly on gcc 4.0 and I believe I have used it with older versions of gcc. Is there something incorrect with my usage? If not, is this an known issue? I searched through the bug tracker and the mailing lists but did not see anything about this bug. Does anyone have any ideas on how to work around this bug? Thanks, Allen

On Jul 10, 2006, at 2:25 PM, Allen Bierbaum wrote:
The following code snippet:
#include <boost/function.hpp>
class TestClass { public: void doSomethingDefault(boost::function2<void, bool, bool>
cb=boost::function2<void,bool,bool>()) {;} };
int main() { TestClass test; test.doSomethingDefault(); return 1; }
Gives an internal compiler error on vc 7.1: [snip]
Is there something incorrect with my usage? If not, is this an known issue? I searched through the bug tracker and the mailing lists but did not see anything about this bug.
Your code looks fine... I've never seen this bug before.
Does anyone have any ideas on how to work around this bug?
Can you just use "= 0" for the default value? Doug

Doug Gregor wrote:
[snip]
Is there something incorrect with my usage? If not, is this an known issue? I searched through the bug tracker and the mailing lists but did not see anything about this bug.
Your code looks fine... I've never seen this bug before.
Does anyone have any ideas on how to work around this bug?
Can you just use "= 0" for the default value?
Great idea and what is better it works. The shear simplicity of this solution floored me. I really should have thought of it sooner. :) Thanks for the help. -Allen
participants (2)
-
Allen Bierbaum
-
Doug Gregor