FIX: Constructor Gets Called Multiple Times on the Same Object (152211)
The information in this article applies to:
- Microsoft Visual C++, 32-bit Editions 4.1
- Microsoft Visual C++, 32-bit Enterprise Edition 4.2
- Microsoft Visual C++, 32-bit Enterprise Edition 5.0
- Microsoft Visual C++, 32-bit Enterprise Edition 6.0
- Microsoft Visual C++, 32-bit Professional Edition 4.2
- Microsoft Visual C++, 32-bit Professional Edition 5.0
- Microsoft Visual C++, 32-bit Professional Edition 6.0
- Microsoft Visual C++, 32-bit Learning Edition 6.0
This article was previously published under Q152211 SYMPTOMS
The constructor gets called more than once on the same global object.
CAUSE
This error occurs when a file has both a global object and a function that
references the global object as extern. In this case, the compiler
incorrectly generates code that calls the constructor on the "extern
myClass object;" statement.
RESOLUTION
Remove the line that contains extern reference to the global. You can
safely remove this line since the global is in file scope.
-or-
Create two separate files, one that contains the global object, and one
that contains the function that references the global object as extern.
STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed
at the beginning of this article.
This problem was corrected in Microsoft Visual C++ .NET.
Modification Type: | Minor | Last Reviewed: | 7/5/2005 |
---|
Keywords: | kbBug kbCompiler kbCPPonly kbfix kbNoUpdate KB152211 |
---|
|