BUG: Access violation occurs when copied objects contain pointers to their own members while using the CArray class in Visual Studio .NET or in Visual Studio 2005 (822369)
The information in this article applies to:
- Microsoft Visual C++ 2005 Express Edition
- Microsoft Visual C++ .NET (2003)
- Microsoft Visual C++ .NET (2002)
- Microsoft Visual C++, 32-bit Professional Edition 6.0
- Microsoft Visual C++, 32-bit Enterprise Edition 6.0
SYMPTOMSThe CArray class may not handle C++ classes correctly. When you
copy objects in memory without using constructors and destructors of the
objects, and you access a member that is a pointer to another member in an object, you may receive an access violation, or an invalid value may be
returned.CAUSEThe CArray Microsoft Foundation Classes (MFC) class uses the memcpy function to copy the objects in
memory. This behavior causes invalid references. When the copied objects contain pointers to
their own members ("this" pointer), the memcpy function may cause invalid
references.WORKAROUNDTo work around this problem, do not use members in an object that are pointers to other
members in the object or to the object itself ("this" pointer) with an
element that is copied.STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are
listed at the beginning of this article.
Modification Type: | Minor | Last Reviewed: | 1/18/2006 |
---|
Keywords: | kbCollectionClass kbProgramming kbbug KB822369 kbAudDeveloper |
---|
|