FIX: Macro Subscript Causes Internal Compiler Error

ID: Q115324

7.00 | 1.00 MS-DOS | WINDOWS kbtool kbfixlist kbbuglist

The information in this article applies to:

SYMPTOMS

The C/C++ compiler, version 8.0, produces the following warning message (followed by an internal compiler error) if the source code at the end of this article is compiled under the large memory model using full optimization:

   warning C4713: internal compiler error: restarting
                  (compiler file '@(#)reg86.c:1.26', line 4600)
   fatal error C1001: internal compiler error
                  (compiler file '@(#)reg86.c:1.26', line 4600)

Under the C/C++ compiler version 7.0, the same warning and error are generated, except that the reg86.c line number is 4479.

Furthermore, using #pragma optimize does not remove both errors. If #pragma optimize is used, only the C1001 error is generated.

CAUSE

The warning and error are generated as a result of using a call to a macro to create a subscript value for accessing an array of structures.

RESOLUTION

Removing the /Oe option from the optimizations causes the C4713 warning to disappear; however, the C1001 error still remains.

There are two ways to get rid of the C1001 error:

STATUS

Microsoft has confirmed this to be a bug in the products listed above. This problem was corrected in Visual C++ for Windows, version 1.5.

MORE INFORMATION

The following sample code can be used to demonstrate the problem:

Sample Code

/* Compile options needed:  /AL /c /Ox
*/ 

#include <stdio.h>

typedef struct flist_links
     {
     long next;
     long prev;
     }
     FLIST_LINKS;

typedef struct mem_flist
     {
     long my_addr;
     long next;
     long prev;
     }
     MEM_FLIST;

typedef struct flist
     {
     FILE *stream;
     int cache_number;
     int flush;
     MEM_FLIST ptrs;
     }
     FLIST;

#define MAX_NAVES_NAME 384
#define NUM_LEVEL_LISTS    6

typedef struct naves_file_struct
     {
     MEM_FLIST whole_list;
     FLIST_LINKS level_list;
     unsigned char flags;
     char name[MAX_NAVES_NAME];
     long verse_list_offset;
     }
     NAVES_FILE_STRUCT;

FLIST WholeList; FLIST LevelLists[NUM_LEVEL_LISTS];

int DeleteNavesEntry(NAVES_FILE_STRUCT *NFS);
int FL_FromList(MEM_FLIST *Element,FLIST *List);

#define GET_NAVES_LEVEL(c) ((c) & (char) 7)

//#pragma optimize("", off)

int DeleteNavesEntry(NAVES_FILE_STRUCT *NFS)
{ MEM_FLIST flist;
int err;

err = FL_FromList(&flist,&LevelLists[GET_NAVES_LEVEL(NFS->flags)]); }

//#pragma optimize("", on)

Additional reference words: 7.00 8.00 1.00 KBCategory: kbtool kbfixlist kbbuglist KBSubcategory: CLIss
Keywords          : kb16bitonly kbCompiler kbbuglist kbfixlist
Version           : 7.00   | 1.00
Platform          : MS-DOS WINDOWS
Solution Type     : kbfix

Last Reviewed: September 22, 1997