home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 6 / FreshFish_September1994.bin / new / dev / c / hce / docs / compilerbugs.doc < prev    next >
Text File  |  1992-09-02  |  2KB  |  75 lines

  1. This document is based on the 'bugs' doc by Detlef Wuerkner and describes
  2. known bugs in the 'HCC' compiler.
  3.  
  4. *************************************************************************
  5. *                            BUG No.1                                   *
  6. *************************************************************************
  7.  
  8.       main()
  9.        {
  10.         char text[] = "Hello";   /* Bad line. */
  11.         printf( "%s\n", text);
  12.         }
  13.  
  14. This would cause error messages 'expect ;' and 'syntax (try skipping...)'
  15. for line 3.
  16.  
  17. If you declared 'text[]' as global like:
  18.  
  19. char text[] = "Hello";
  20.  
  21.       main()
  22.         {
  23.          printf( "%s\n", text);
  24.          }
  25.  
  26. or as a char pointer:
  27.  
  28.       main()
  29.         {
  30.          char *text = "Hello";
  31.          printf( "%s\n", text);
  32.          }
  33.  
  34. then everything would be ok.
  35. This error seems to happen because 'text' is handled as a pointer to a 
  36. null terminated array of char.
  37.  
  38. *************************************************************************
  39. *                            BUG No.2                                   *
  40. *************************************************************************
  41.  
  42.  
  43.       struct xx {
  44.                    struct xx *ptr;
  45.                  } 
  46.                 dummy[2] = {
  47.                                {
  48.                                 &dummy[1]   /* Bad line. (line 6) */
  49.                                 },
  50.                                {
  51.                                 &dummy[0]   /* Bad line. (line 9) */
  52.                                 },
  53.                             };
  54.  
  55. This would cause 'undefined: dummy' error messages for lines 6 and 9 and
  56. also cause other error messages. This is because the 'dummy' structure is not
  57. defined until the end of the structure declaration and references made to
  58. 'dummy' before then are invalid.
  59.  
  60. The correct way:
  61.  
  62.   extern struct xx {                /* use 'extern' and declare the struct */
  63.                    struct xx *ptr;  /* in advance. */
  64.                  } dummy[2];
  65.  
  66.         struct xx dummy[2] = {
  67.                                {
  68.                                  &dummy[1]
  69.                                 },
  70.                                {
  71.                                  &dummy[0]
  72.                                 },
  73.                             };
  74.  
  75.