Microsoft KB Archive/315946

From BetaArchive Wiki
Knowledge Base


BUG: You receive error message C1001 when you try to convert the managed parameter constructor std::string& to std::string in Viosual Studio .NET

Article ID: 315946

Article Last Modified on 8/24/2005



APPLIES TO

  • Microsoft Visual Studio .NET 2002 Professional Edition
  • Microsoft Visual Studio .NET 2002 Enterprise Architect
  • Microsoft Visual Studio .NET 2002 Enterprise Developer
  • Microsoft Visual Studio .NET 2002 Academic Edition
  • Microsoft Visual Studio .NET 2003 Academic Edition
  • Microsoft Visual Studio .NET 2003 Enterprise Developer
  • Microsoft Visual Studio .NET 2003 Enterprise Architect
  • Microsoft Visual Studio .NET 2003 Professional Edition



This article was previously published under Q315946

SYMPTOMS

In Microsoft Visual Studio .NET, when you try to convert the managed parameter constructor std::string& to std::string, you receive the following error message:

"fatal error C1001: INTERNAL COMPILER ERROR (compiler file 'f:\vs70builds\9288\vc\Compiler\Utc\src\P2\main.c', line 146)"

RESOLUTION

Change the constructor so that it requires its argument to be copy constructed.

STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

MORE INFORMATION

Steps to Reproduce the Behavior

  1. Create a Managed Extensions for C++ application named Test. Delete the existing code in Test.cpp, and then paste the following sample code:

    /* test.cpp*/ 
    
    #include "stdafx.h"
    
    #using <mscorlib.dll>
    #include <string> 
    public __gc class Hello { 
    public: 
    Hello(std::string arg) {} 
    };
    
     
    public __gc class There { 
    public: 
     void Something(const std::string &arg) { 
      Hello *hello = new Hello(arg); 
     } 
    }; 
    
    
    void main()
    {
    There *there = new There(); 
    there->Something("world"); 
    }
                        
  2. Do one of the following:
    • Use the integrated development environment (IDE) to build the project.

      -or-
    • Compile the file in Visual Studio .NET by typing the following at a command prompt: cl /clr /EHsc test.cpp


Keywords: kbbug kbpending kbvs2002sp1sweep KB315946