home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / gnu / gcc / bug / 3162 < prev    next >
Encoding:
Text File  |  1993-01-11  |  1.4 KB  |  84 lines

  1. Newsgroups: gnu.gcc.bug
  2. Path: sparky!uunet!cis.ohio-state.edu!romulus.CRay.COM!kessler
  3. From: kessler@romulus.CRay.COM (Richard Kessler  {66651 CF/DEV})
  4. Subject: gcc bug report
  5. Message-ID: <9301112228.AA05135@trek.cray.com>
  6. Sender: gnulists@ai.mit.edu
  7. Organization: GNUs Not Usenet
  8. Distribution: gnu
  9. Date: Mon, 11 Jan 1993 22:28:29 GMT
  10. Approved: bug-gcc@prep.ai.mit.edu
  11. Lines: 71
  12.  
  13. /*
  14.  
  15. GCC BUG: bad code with nested switches and double-length
  16.    integers.
  17.  
  18. This is example code to exercise a gcc bug.
  19.  
  20. On a "sparc-sun-sunos4.1" with gcc version 2.2.2, the
  21. following code core dumps. I used "gcc -ggdb file.c" to
  22. compile.
  23.  
  24.  I can fix it by: (a) the "#define switch(a) switch((int)(a))"
  25. below, or (b) "typedef int longint" instead of
  26. "typedef long long longint". The nested switch also seems
  27. important; I don't think it will core dump with just one
  28. switch level.
  29.  
  30. It coredumps on the outermost "switch".
  31.  
  32. */
  33.  
  34. #include <stdio.h>
  35. /*
  36. #define switch(a) switch((int)(a))
  37. */
  38.  
  39. typedef long long longint;
  40. void main(void);
  41. void wwrite(longint);
  42.  
  43. void main(void)
  44. {
  45.     wwrite((longint) 0);
  46. }
  47.  
  48. void wwrite(longint i)
  49. {
  50.     longint j = 0;
  51.  
  52.     switch(i)
  53.     {
  54.     case 1:
  55.     case 2:
  56.     case 3:
  57.     case 4:
  58.     case 5:
  59.     case 6:
  60.     case 7:
  61.     case 0xa:
  62.     case 0x1c:
  63.         j = 1;
  64.     case 23:
  65.         switch(j)
  66.         {
  67.         case 0:
  68.             printf("hello\n");
  69.             break;
  70.         case 1:
  71.             printf("bye\n");
  72.             break;
  73.         }
  74.         break;
  75.     case 47:
  76.         printf("hi\n");
  77.         break;
  78.     default:
  79.         printf("ho\n");
  80.         break;
  81.     }
  82. }
  83.  
  84.