Article ID: 140188 - Last Review: July 5, 2005 - Revision: 1.1 FIX: C1001 or C2434: Using Templates in Default ArgumentsThis article was previously published under Q140188 On This PageSYMPTOMS
The compiler generates either an internal compiler error C1001 or a C2434
error when using the Minimal Rebuild option with code that contains:
fatal error C1001: INTERNAL COMPILER ERROR
(compiler file 'msc1.cpp', line 899)
-or-
error C2434: cannot convert default argument from 'type1' to 'type2'
CAUSE
The error occurs when processing the non-trivial default argument of a
member function of a class that requires instantiating a template class
for the first time.
The error occurs when the compiler is forced to instantiate a template class for the first time in a default-argument expression because it needs to record information about the class for Minimal Rebuild purposes. One function is destroying data required by a function that is further down the call stack. The compiler generates a syntax error depending on how it interprets the destroyed data. If the compiler cannot make sense of the destroyed data, it will generate an Internal Compiler Error C1001. Depending on the code, the errors C1001 or C2434 may only occur when using one or more of these compiler options: /Gm Enable Minimal Rebuild /GX Enable Exception Handling /Zi Create CodeView type Debug Information in a PDB file RESOLUTION
STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed
at the beginning of this article. This problem was corrected in Microsoft Visual C++ .NET. MORE INFORMATION
The following sample code demonstrates the problem and generates the
incorrect error C2434. The workaround in the comment below is to explicitly
instantiate the template class (X<int>) before using it in a default-
argument expression.
Sample CodeAPPLIES TO
| Article Translations
|
Back to the top
