Microsoft KB Archive/263637

= BUG: Class Access Specifier Is Ignored When Temporary Objects Are Created =

Article ID: 263637

Article Last Modified on 7/5/2005

-

APPLIES TO


 * Microsoft Visual C++ 5.0 Enterprise Edition
 * Microsoft Visual C++ 5.0 Professional Edition
 * Microsoft Visual C++ 6.0 Enterprise Edition
 * Microsoft Visual C++ 6.0 Professional Edition
 * Microsoft Visual C++ 6.0 Standard Edition

-



This article was previously published under Q263637



SYMPTOMS
The compiler incorrectly uses private or protected constructors when temporary class objects are created.

NOTE: The compiler generates a C4248 warning if compiled with the /W3 or /W4 compiler switch.

Please refer to the sample code in the &quot;More Information&quot; section for details.



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



Steps to Reproduce Behavior
The following sample code demonstrates the bug: // Test.cpp // Compiler option needed: /GX class A { protected: A(int i) : m_i(i) {} private: int m_i; };

int main { //A a(8); // Error C2248 here, as expected. A(8); // No error here. // Produces warning C4248 with compiler switch /W3 or /W4.

try {       throw A(8); // No error here also. // Produces warning C4248 with compiler switch /W3 or /W4. }   catch (A& a)    { }

return 0; }

Keywords: kbbug kbcpponly kbcompiler KB263637

-

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

© Microsoft Corporation. All rights reserved.