Microsoft KB Archive/115710

{|
 * width="100%"|

BUG: /Za Compiler Option Causes Errors with "
" Operator ==
 * }

Q115710

1.00 1.50 WINDOWS kbtool kbbuglist -- The information in this article applies to: - The Microsoft C/C++ Compiler (CL.EXE), included with: - Microsoft Visual C++ for Windows, versions 1.0 and 1.5 -- SYMPTOMS ======== The equal to operator ("==") may cause the compiler to generate different errors when the /Za compiler option (Disable Microsoft Extensions) is used. C/C++ version 8.0 will generate the following DOSXNT error when built with the /Za and /Bd option: fatal error DX1020: unhandled exception: General protection fault If the /Bd option is omitted, the compiler will generate the following DOSXNT error DX2010: invalid pointer passed to free or realloc. C/C++ version 8.0c will cause a stack overflow during compile if the /Za and /Bd options are used, but will cause the following internal compiler error if compiled with just the /Za option: test.cpp(27) : fatal error C1001: internal compiler error (compiler file 'msc1.cpp', line 585) RESOLUTION ========== The example below illustrates the problem with the following statement: if( a == test); where test returns a instance of the BB class and the equal to operator can only compare instances of the A class with instances of the B class. By writing an equal to operator to compare A class objects to BB class objects, the error will not be generated. STATUS ====== Microsoft has confirmed this to be a problem with the C/C++ compiler for MS-DOS, versions 8.0 and 8.0c. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available. The problem does not occur with the C/C++ 32-bit compiler, version 8.0. MORE INFORMATION ================ The sample code below may be used to reproduce this problem. To invoke the /Za option from within the Visual Workbench, choose Project from the Options menu, then choose Compiler. Select the Custom Options category from the Compiler Options dialog box, then check Disable Microsoft Language Extensions. With the sample code, use an MS-DOS Executable as the project target. Sample Code --- /* Compile options needed: /Za */ typedef class B { public: int val(void) const {return 1;} } B; typedef class BB:public B { } BB; typedef class A { public: // int operator==(const BB &b) const {return b.val;} int operator==(const B &b) const {return b.val;} } A; BB test(void) { BB b; return b; } void main(void) { A a; if( a==test ); } Additional reference words: 1.00 1.50 8.00 8.00c KBCategory: kbtool kbbuglist KBSubcategory: CPPIss

Keywords : kb16bitonly

Issue type : kbbug

Technology : kbVCsearch kbAudDeveloper kbCVCComp