BUG: Function Defined in Local Class Causes C1001

Last reviewed: July 22, 1997
Article ID: Q115856
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, 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 reference words: 1.50 8.00c
KBCategory: kbtool kbbuglist
KBSubcategory: CPPIss
Keywords : kb16bitonly


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: July 22, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.