BUG: Internal Compiler Error: MSC1.CPP, Line 585 or 581

Last reviewed: July 22, 1997
Article ID: Q113112
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

Compiling the sample code shown below causes the compiler to incorrectly generate one of the following error messages:

   fatal error C1001 : internal compiler error
    ( compiler file 'msc1.cpp', line 585 )

   -or-

   fatal error C1001 : internal compiler error
    ( compiler file 'msc1.cpp', line 581 )

CAUSE

Partially initializing an array of structures that is a field of another structure (referred to as an "aggregate") causes the compiler to generate internal compiler errors. The compiler does not generate an error if using a .C file. The example shown below illustrates this:

   typedef struct Element
   {
     int   field1;
     char *field2;
   }
   ELEMENT;

   typedef struct Aggregate
   {
     ELEMENT list[5];
   }
   AGGREGATE;

Defining and initializing a variable using:

   AGGREGATE mylist = {  1, "one",
                         2, "two",
                         3, "three",
                         4, "four"
                      };     // Internal compiler error C1001.

RESOLUTION

There are three workarounds to this problem:

  • Use an array instead of a single variable. For example:

          AGGREGATE mylist[] = { 1, "one",
    
                                 2, "two",
                                 3, "three",
                                 4, "four"
                               };
       -or-
    
    
  • Initialize all the members in the aggregate.

    -or-

  • If possible, compile the file as a .C file instead of a .CPP file.

STATUS

Microsoft has confirmed this to be a problem with C/C++ 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.

This is not a problem in Visual C++ 32-bit Edition.

MORE INFORMATION

In C++, when an aggregate is initialized, the initializer is a list of brace-enclosed, comma-separated initializers for the members of the aggregate in increasing sequence or member order. This rule applies recursively to the members of the subaggregates if there are any. If fewer initializers are in the list than the members of the aggregate, then the remaining members are padded with zeroes of the appropriate types.

Sample Code

/* Compile options needed: /c
*/

typedef struct Element {
  int   field1;
  char *field2;
} ELEMENT;

typedef struct Aggregate {

  ELEMENT list[5];
} AGGREGATE;

void main(void)
{
  AGGREGATE mylist = {
                        1, "one" ,
                        2, "two" ,
                        3, "three" ,
                        4, "four"
                     };
}


Additional reference words: 1.00 1.50 8.00 8.00c
KBCategory: kbtool kbbuglist
KBSubcategory: CLIss
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.