C9005000: C1001: regMD.c, Line 4634

ID Number: Q62329

6.00 | 6.00

MS-DOS | OS/2

buglist6.00 fixlist6.00a

Summary:

SYMPTOMS

The Microsoft C Compiler version 6.0 produces the following internal

compiler error when the sample programs below are compiled for large

(/AL) or compact (/AC) memory model:

fatal error C1001: Internal Compiler Error

(compiler file '@(#)regMD.c:1.100', line 4634)

Contact Microsoft Product Support Services

RESOLUTION

This error can occur with various optimizations. In general, compiling

with /Od (no optimization) or /Ox (maximum save optimization) will

work correctly. In the examples, there are various "failsafe"

optimizations that can cause the error to go away. If one of these

optimizations is used on a compile line that would otherwise cause the

internal compiler error, the error will not appear.

STATUS

Microsoft has confirmed this to be a problem in C version 6.0. This

problem was corrected in C version 6.0a.

More Information:

Sample Code

-----------

/** Code Sample1 **/

struct str

{

int *a;

int b;

};

void func(struct str * w)

{

dog( w->a[(*w).b], w->a[w->b+1] & w->a[w->b]);

}

In this example, using any combination that doesn't include /Oe will

result in the above error. As soon as /Oe is included, the error

doesn't occur. For example:

cl /c /AL /Oacgilnprstwz file.c << Fails with error.

cl /c /AL /Oacgilnprstwze file.c << Works correctly, no error.

cl /c /AL /Oanprswzx file.c << Also works correctly.

In the second working compile line, remember that /Ox includes /Oe

(actually /Ox = /Ocegilt /Gs).

/** Code Sample2 **/

struct cat{

int x;

int y;

int dog[7];

};

void g(struct cat c1[0][1])

{

int a=0;

int b=0;

unsigned int c=0;

char buf[1];

if(0);

buf[0] = c1[a][b].x << 1 + c1[a][b].y;

buf[0] = c + c1[a][b].x;

}

In the above example, using /Oe will correct the problem. However, /Ol

and /Og will also work correctly. Again, any combination of the other

optimizations will result in the above error until one of the

"failsafe" optimizations is used.

If you want to change the code in the program, the following are some

code sequences that seem to cause the error:

1. Global struct

2. Structure passed to function

3. Complex dereference of structure member

Usually, modifying the code to change this sequence will cause the

error to go away. For instance, in example 2, any of the following

changes will eliminate the error:

1. Change dog[7] to dog [6] and declare a dummy int to pad the

structure.

2. Change "c" from an unsigned int to int.

3. Change the order of the code or use a temporary variable in the

assignment statement.

Additional reference words: 6.00