FIX: C1001 Caused in Switch Statements for C 6.0 and 7.0
PSS ID Number: Q108770
Article last modified on 02-01-1994

6.00 6.00a 6.00ax 7.00 | 6.00 6.00a

MS-DOS                 | OS/2


----------------------------------------------------------------------
The information in this article applies to:

 - Microsoft C compiler for MS-DOS, versions 6.0, 6.0a, and 6.0ax
 - Microsoft C compiler for OS/2, versions 6.0 and 6.0a
 - Microsoft C/C++ compiler for MS-DOS, version 7.0
----------------------------------------------------------------------

SYMPTOMS
========

The following internal compile errors may be generated when using case
statements containing a call to strcpy().

With C version 6.x the error generated is:

   fatal error C1001: Internal Compiler Error
   (compiler file '@(#)newcode.c:1.87', line 551)

With C version 7.0 the error generated is:

   fatal error C1001: INTERNAL COMPILER ERROR
   (compiler file '@(#)code.c:1.25', line 421)

RESOLUTION
==========

There are several ways to correct this problem:

 - Don't let a case statement containing a call to strcpy() have the
   highest case value.

  -or-

 - Remove either the /0l, /Oe, or /Oi optimization from the command line.

  -or-

 - Use the #pragma optimize directive to turn off either the /0l, /Oe, or
   /Oi optimization for that function.

STATUS
======

This problem has been corrected in Microsoft version 8.0.

MORE INFORMATION
================

The sample code below generates the C1001 error only if a case statement
with the highest case value contains a strcpy(), and the /Olei
optimizations are being performed.

Sample Code
-----------

/* Compile options needed: /f- /Olei /AL or /AC
*/

#include <stdarg.h>
#include <string.h>

union union1
{¬
  char *c;
  int *i;
};

union union2
{¬
  int i;
};

int in_list(char prompt[], ...)
{¬
  int i;
  int count;
  int param_type[22];
  union union1 var1[22];
  union union1 var2[22];
  union union2 var3[22];
  char **optionstr[22];
  int *option[22];
  va_list arg_ptr;

  va_start(arg_ptr, prompt);

  for(count = 0; count < 22; count++)
  {¬
    param_type[count] = va_arg(arg_ptr, int);
    switch(param_type[count] & 0x00FF)
    {¬
      case 13:
           strcpy(var2[count].c, var1[count].c);
           break;
      case 7:
           var1[count].i = va_arg(arg_ptr, int *);
           var2[count].i = va_arg(arg_ptr, int *);
           for(i=0; (optionstr[count][i] != NULL) &&
                     (option[count][i] != *var1[count].i); i++) ;
           if(optionstr[count][i] == NULL)
             *var2[count].i = *var1[count].i = option[count][0];
           else *var2[count].i = *var1[count].i;
           break;
      case 8:
           strcpy(var2[count].c, var1[count].c);
           break;
      case 9:
           strcpy(var2[count].c, var1[count].c);
           break;
      case 10:
           strcpy(var2[count].c, var1[count].c);
           break;
      case 11:
           var1[count].i = va_arg(arg_ptr, int *);
           var2[count].i = va_arg(arg_ptr, int *);
           *var1[count].i = var3[count].i;
           break;
    }
  }
}

Additional reference words: buglist6.00a buglist6.00ax 6.00 7.00 6.00a
6.00ax
KBCategory: Tls
KBSubcategory:

=============================================================================

Copyright Microsoft Corporation 1994.
