home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 14 Text / 14-Text.zip / C6_BUGS.ZIP / C6_20072.BUG < prev    next >
Text File  |  1990-09-11  |  2KB  |  113 lines

  1. Q63054 Case Lost in Complex Switch Statement in C 6.00
  2. Microsoft C Compiler (C)
  3. 6.00   | 6.00
  4. MS-DOS | OS/2
  5.  
  6. Summary:
  7.  
  8. Under certain circumstances, a case may be lost in a complex switch
  9. statement under default optimizations with Microsoft C version 6.00.
  10.  
  11. More Information:
  12.  
  13. The following code demonstrates the problem by losing track of case
  14. 30. To work around the problem, disable optimizations or add /Os via
  15. the command-line switches or through the use of the optimize pragma.
  16.  
  17. Sample Code
  18. -----------
  19.  
  20. #include <stdio.h>
  21.  
  22. int cm_lockup( void ) ;
  23.  
  24. int main( void )
  25. {
  26.    int j;
  27.  
  28.    switch( 30 )
  29.    {
  30.       case 7:
  31.       case 43:
  32.           j = 1;
  33.  
  34.       case 8:
  35.           ++j;
  36.  
  37.       case 35:
  38.           ++j;
  39.  
  40.       case 137:
  41.           break;
  42.  
  43.       case 33:
  44.       case 39:
  45.           j = 3;
  46.           break;
  47.  
  48.       case 30:           // this case is missed
  49.           j = 4;
  50.           break;
  51.  
  52.       case 12:
  53.           j = 5;
  54.           break;
  55.  
  56.       case 11:
  57.       case 32:
  58.           j = 6;
  59.           break;
  60.  
  61.       case 10:
  62.           j = 7;
  63.           break;
  64.  
  65.       case 2:
  66.           j = 8;
  67.           break;
  68.  
  69.       case 37:
  70.           j = 9;
  71.           break;
  72.  
  73.       case 6:
  74.           j = 10;
  75.           break;
  76.  
  77.       case 13:
  78.           break;
  79.  
  80.       case 44:
  81.           j = 11;
  82.           break;
  83.  
  84.       case 41:
  85.           j = 12;
  86.           break;
  87.  
  88.       case 42:
  89.           j = 13;
  90.           break;
  91.  
  92.       default:
  93.           cm_lockup();
  94.           break;
  95.    }
  96.    return j;
  97. }
  98.  
  99. int cm_lockup( )
  100. {
  101.    printf( "bad" );
  102.    return 1;
  103. }
  104.  
  105. Microsoft has confirmed this to be a problem with C version 6.00. We
  106. are researching this problem and will post new information here as it
  107. becomes available.
  108.  
  109. Keywords:  buglist6.00
  110.  
  111. COPYRIGHT Microsoft Corporation, 1990.
  112. Updated  90/07/26 05:20
  113.