KnowledgeBase Archive

An Archive of Early Microsoft KnowledgeBase Articles

View on GitHub

Q221585: FIX: C1001 - Internal Compiler Error on String Default Argument

Article: Q221585
Product(s): Microsoft C Compiler
Version(s): winnt:5.0sp3
Operating System(s): 
Keyword(s): kbVS97sp3bug
Last Modified: 07-MAY-2001

-------------------------------------------------------------------------------
The information in this article applies to:

- Microsoft Visual C++, 32-bit Enterprise Edition, version 5.0sp3 
- Microsoft Visual C++, 32-bit Professional Edition, version 5.0sp3 
-------------------------------------------------------------------------------

SYMPTOMS
========

Compiling code with a default argument for a string parameter in a function
declaration results in the following:

  Test.cpp() : fatal error C1001: INTERNAL COMPILER ERROR
               (compiler file 'msc1.cpp', line 1188)
      Please choose the Technical Support command on the Visual C++
      Help menu, or open the Technical Support help file for more information

CAUSE
=====

This bug was introduced in Visual Studio 97 Service Pack 3. It was not in
earlier versions of Visual C++ 5.0.

RESOLUTION
==========

Either upgrade to Visual C++ 6.0, or define a string in the file before the
function declaration.

STATUS
======

Microsoft has confirmed this to be a problem in the Microsoft products that are
listed at the beginning of this article.

This bug was corrected in Microsoft Visual C++, version 6.0.

MORE INFORMATION
================

The following sample code demonstrates the problem and the workaround:

  #include <string>
  using namespace std ;

  // Uncomment the following line to work around the problem
  //static std::string empty = ""; 

  void test( string sname = "" );

  void main()
  {
     test( ) ;
  }

Note that the empty string declaration must be in the same translation unit as
the function declaration.


Additional query words:

======================================================================
Keywords          : kbVS97sp3bug 
Technology        : kbVCsearch kbAudDeveloper kbVC32bitSearch kbVC500SP3 kbVC500Search
Version           : winnt:5.0sp3
Issue type        : kbbug
Solution Type     : kbfix

=============================================================================

THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Copyright Microsoft Corporation 1986-2002.