Microsoft KB Archive/823929

= BUG: C1001 error occurs while accessing a property by using a smart pointer in a struct member =

Article ID: 823929

Article Last Modified on 1/18/2006

-

APPLIES TO


 * Microsoft Visual C++ .NET 2003 Standard Edition
 * Microsoft Visual C++ .NET 2002 Standard Edition

-





SYMPTOMS
When you access a property through a smart pointer for a struct member, you may receive the following internal compiler error message:

fatal error C1001: INTERNAL COMPILER ERROR

(compiler file 'f:\vs70builds\9466\vc\Compiler\CxxFE\sl\P1\C\toil.c', line 7021)

Note The file name, the full path, and the line number may vary with the compiler build that you use.



WORKAROUND
To work around this bug, copy the contents of the property that are accessed by a smart pointer to a temporary variable, and then use the copied value in a struct member. The following is the modified code: void main { CoInitialize(NULL); IPtr p(__uuidof(C)); struct s { int number; wchar_t* string; };       wchar_t* str1 = p->a; wchar_t* str2 = p->b; s impl[2] = { {0, str1}, {1, str2} };   p = 0; CoUninitialize; }
 * 1) import &quot;TestServer.dll&quot; no_namespace



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



Create a Component Object Model (COM) Component
  Paste the following code in Notepad: [module(name=ldld)]; [dispinterface] __interface I { [id(1)] BSTR a;   [id(2)] BSTR b; }; [coclass] struct C : I { void put_a(BSTR x) {} void put_b(BSTR x) {} BSTR get_a { return 0; } BSTR get_b { return 0; } };  Save the file as TestServer.cpp in the c:\TestServer folder. Open the Visual Studio .NET command prompt.  Change the directory to C:\TestServer. Run the following command at the command prompt to create a COM Server: cl /LD TestServer.cpp 
 * 1) define _ATL_ATTRIBUTES 1
 * 2) include 
 * 3) include <atlcom.h>

Create a COM Client
  Open a new instance of Notepad, and then paste the following code: void main { CoInitialize(NULL); IPtr p(__uuidof(C)); struct s { int number; wchar_t* string; };         s impl[2] = { {0, p->a}, {1, p->b} };   p = 0; CoUninitialize; } </li> Save the file as TestClient.cpp in the C:\TestServer folder.</li>  At the Visual C++ .NET command prompt, run the following command: cl /GX TestClient.cpp You may receive the compilation error that the &quot;Symptoms&quot; section describes. </li></ol>
 * 1) import &quot;TestServer.dll&quot; no_namespace

Keywords: kberrmsg kbbug kbsmartptr kbcompiler KB823929

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.