Microsoft KB Archive/115856

From BetaArchive Wiki

BUG: Function Defined in Local Class Causes C1001

Q115856



The information in this article applies to:


  • The C/C++ Compiler (CL.EXE), included with:
    • Microsoft Visual C++, version 1.5





SYMPTOMS

The code shown below will generate the following errors on computers running MS-DOS:

error C2601: functions cannot be defined in local classes
error C2517: 'C_char' : right of '::' is undefined
error C2510:  : left of '::' must be a class/struct/union
error C2270: '.PAD' : modifiers not allowed on nonmember functions
error C2065: 'storage' : undeclared identifier
error C2440: 'return' : cannot convert from 'char __near *' to 'int '
error C2618: '.PAD' : inconsistent return statement


These errors are expected.

On computers running Windows NT, the first two errors are generated by the, compiler, but the other errors are not. Instead, the following error is reported:

fatal error C1001: internal compiler error

(compiler file 'msc1.cpp', line 585)



RESOLUTION

To resolve the problem in the sample code below, declare zot as a global variable.



STATUS

Microsoft has confirmed this to be a problem with the C/C++ compiler for MS-DOS, version 8.0c. We are researching the problem and will post new information here as it becomes available.

This is not a problem with the 32-bit C/C++ compiler.



MORE INFORMATION

The following sample can be used to demonstrate this problem.

Sample Code

/* Compile options needed: none
*/ 
#include <iostream.h>
#define C(type) \ 
  class C_ ## type {  \ 
     void* storage;  \ 
   public: \ 
     operator type*() { return (type*)storage; }  \ 
  }
// uncomment the following line and comment the same line
// in f() to fix the problem
// C(char) zot;
void f()
{
   C(char) zot;
}
void main ( void )
{
   cout << "PASSED" << endl;
} 

Additional query words: 1.50 8.00c

Keywords : kb16bitonly
Issue type : kbbug
Technology : kbVCsearch kbAudDeveloper kbCVCComp


Last Reviewed: May 8, 2001
© 2001 Microsoft Corporation. All rights reserved. Terms of Use.