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



The information in this article applies to:

  • Microsoft Visual Studio .NET (2002), Professional Edition
  • Microsoft Visual Studio .NET (2002), Enterprise Architect Edition
  • Microsoft Visual Studio .NET (2002), Enterprise Developer Edition
  • Microsoft Visual Studio .NET (2002), Academic Edition
  • Microsoft Visual Studio .NET (2003), Academic Edition
  • Microsoft Visual Studio .NET (2003), Enterprise Developer Edition
  • Microsoft Visual Studio .NET (2003), Enterprise Architect Edition
  • 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

Modification Type:MinorLast Reviewed:8/24/2005
Keywords:kbvs2002sp1sweep kbbug kbpending KB315946