ID Number: Q63054
6.00 | 6.00
MS-DOS | OS/2
buglist6.00 fixlist6.00a
Summary:
Under certain circumstances, a case may be lost in a complex switch
statement under default optimizations with Microsoft C version 6.0.
More Information:
The following code demonstrates this problem in a situation where the
case expression is 30. To work around the problem, disable
optimizations or add /Os via the command-line switches or through the
use of the optimize pragma.
Microsoft has confirmed this to be a problem in C version 6.0. This
problem was corrected in C version 6.0a.
Sample Code
-----------
/* Compile options needed: none
*/
#include <stdio.h>
int cm_lockup( void ) ;
int main( void )
{
int j;
switch( 30 )
{
case 7:
case 43:
j = 1;
case 8:
++j;
case 35:
++j;
case 137:
break;
case 33:
case 39:
j = 3;
break;
case 30: // this case is missed
j = 4;
break;
case 12:
j = 5;
break;
case 11:
case 32:
j = 6;
break;
case 10:
j = 7;
break;
case 2:
j = 8;
break;
case 37:
j = 9;
break;
case 6:
j = 10;
break;
case 13:
break;
case 44:
j = 11;
break;
case 41:
j = 12;
break;
case 42:
j = 13;
break;
default:
cm_lockup();
break;
}
return j;
}
int cm_lockup( )
{
printf( "bad" );
return 1;
}