home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / gnu / gcc / bug / 3082 < prev    next >
Encoding:
Text File  |  1992-12-30  |  11.0 KB  |  299 lines

  1. Newsgroups: gnu.gcc.bug
  2. Path: sparky!uunet!cis.ohio-state.edu!netcom.com!rfg
  3. From: rfg@netcom.com (Ronald F. Guilmette)
  4. Subject: Twenty bugs reports for GCC 2.3.3
  5. Message-ID: <1992Dec30.010044.10118@netcom.com>
  6. Sender: gnulists@ai.mit.edu
  7. Organization: Netcom - Online Communication Services  (408 241-9760 guest)
  8. Distribution: gnu
  9. Date: Wed, 30 Dec 1992 01:00:44 GMT
  10. Approved: bug-gcc@prep.ai.mit.edu
  11. Lines: 286
  12.  
  13. I have just finished running my own tests on the recently released GCC 2.3.3.
  14. These tests reveal twenty bugs, all of which are described below.
  15.  
  16. The tests were run on a copy of GCC 2.3.3 which was the final product of a
  17. full three stage bootstrap for/on an i486 system running SVR4.  (The target
  18. configuration for the compiler was i486-svr4.)
  19.  
  20. All tests were run with the following GCC options in effect:
  21.  
  22.     -ansi -pedantic-errors -fno-common -w -O
  23.  
  24. Note that the -O (optimization) option seems to have no relevance to any of
  25. the bugs I have found.
  26.  
  27. Also note that most of the bugs described below are "platform independent"
  28. and I would expect them to also afflict GCC when it is hosted and/or targeted
  29. to platforms other than i486/svr4 also.
  30.  
  31. Most (but not all) of these twenty bugs are problems with standard conformance.
  32. GCC is either issuing errors for valid ANSI C code or else it is failing to
  33. issue errors for constructs which violate some constraint given in the ANSI
  34. C standard.
  35.  
  36. -----------------------------------------------------------------------------
  37. #1)  GCC fails to detect the error in the following code, even when the
  38.      -pedantic-errors option is used.
  39.  
  40. void foo ()
  41. {
  42.   extern void bar (int i, ...);
  43.  
  44.   bar (99, 88, 77);
  45. }
  46.  
  47. void bar (int i, int j, int k) { }      /* ERROR */
  48. -----------------------------------------------------------------------------
  49. #2)  GCC fails to detect the error in the following code, even when the
  50.      -pedantic-errors option is used.
  51.  
  52. unsigned long overflow = LONG_MAX + 3; /* ERROR */
  53. -----------------------------------------------------------------------------
  54. #3)  GCC incorrectly flags an error on the following standard-conformant code
  55.      when the -pedantic-errors option is in effect.
  56.  
  57. typedef int T;
  58. void test_1 (int T) { }
  59. -----------------------------------------------------------------------------
  60. #4)  On x86 machines, GCC fails to properly implement explicit floating-point
  61.      casts of those floating-point expressions which get evaluated using the
  62.      (internal) 80-bit floating-point format.  This causes the following
  63.      program to yield a non-zero exit status.
  64.  
  65. double point_four = 0.4;
  66. double point_one_six;
  67.  
  68. int
  69. main ()
  70. {
  71.   point_one_six = (point_four * point_four);
  72.   if ((double)(point_four * point_four) != point_one_six)
  73.     {
  74.       return 1;
  75.     }
  76.   return 0;
  77. }
  78. -----------------------------------------------------------------------------
  79. #5)  GCC incorrectly issues an error for the following standard-conformant
  80.      code.  (Note that `wchar_t' is the same as type `long int' on i486-svr4.)
  81.  
  82. typedef long int wchar_t;
  83. wchar_t array5[4] = L"abcd";
  84. -----------------------------------------------------------------------------
  85. #6)  The following erroneous code causes GCC to crash with a signal 6.
  86.  
  87. extern volatile struct s evs;
  88. void evs_test () { evs; }
  89. -----------------------------------------------------------------------------
  90. #7)  When compiling an empty source file while the -pedantic-errors option
  91.      is in effect, GCC will generate an error message for a line number which
  92.      does not actually exist in the source file.  (The line number indicated
  93.      in the error message is equal to the number of lines actually in the
  94.      file plus one.)  Issuing error messages which reference non-existant
  95.      source lines may cause some related tools (e.g. emacs) to go bonkers.
  96. -----------------------------------------------------------------------------
  97. #8)  GCC fails to issue errors for the following erroneous code, even when
  98.      the -pedantic-errors option is in effect.  (Note that the argument type
  99.      for the function is *not* a type which would result from integral
  100.      promotions.)
  101.  
  102. void test_0 (char);
  103. void test_0 (c) char c; { }
  104. -----------------------------------------------------------------------------
  105. #9)  GCC fails to issue errors in cases where a static function is referenced
  106.      but never defined, even when the -pedantic-errors option is used.
  107.  
  108.      Example:
  109.  
  110. static void s (); int main () { s (); return 1; }
  111. -----------------------------------------------------------------------------
  112. #10)  GCC fails to issue an error for the following invalid C code, even when
  113.       the -pedantic-errors option is used.
  114.  
  115. void (*func_ptr) ();
  116. int i;
  117. void test () { func_ptr = i ? 0 : 0; }         /* ERROR */
  118. -----------------------------------------------------------------------------
  119. #11)  GCC fails to issue errors for the following invalid C code involving
  120.       comparison operators, even when the -pedantic-errors option is used.
  121.  
  122. typedef int b_array[3];
  123. typedef int u_array[];
  124.  
  125. typedef b_array *b_array_ptr;
  126. typedef u_array *u_array_ptr;
  127.  
  128. b_array b_array_src;
  129. extern u_array u_array_src;
  130. int *ip;
  131. int i;
  132. b_array_ptr b_array_dest;
  133. u_array_ptr u_array_dest;
  134.  
  135. void test_relational_operators ()
  136. {
  137.   i = & u_array_src > & b_array_src;            /* ERROR */
  138.   i = & b_array_src > & u_array_src;            /* ERROR */
  139.  
  140.   i = & u_array_src <= & b_array_src;           /* ERROR */
  141.   i = & b_array_src <= & u_array_src;           /* ERROR */
  142.  
  143.   i = u_array_dest > b_array_dest;              /* ERROR */
  144.   i = b_array_dest > u_array_dest;              /* ERROR */
  145.  
  146.   i = u_array_dest <= b_array_dest;             /* ERROR */
  147.   i = b_array_dest <= u_array_dest;             /* ERROR */
  148. }
  149.  
  150. int u_array_src[20] = { 0 };    /* complete its type */
  151. -----------------------------------------------------------------------------
  152. #12)  GCC fails to issue errors for the following invalid C code involving
  153.       the binary `-' operator, even when the -pedantic-errors option is used.
  154.  
  155. typedef int b_array[3];
  156. typedef int u_array[];
  157.  
  158. typedef b_array *b_array_ptr;
  159. typedef u_array *u_array_ptr;
  160.  
  161. b_array b_array_src;
  162. extern u_array u_array_src;
  163. int *ip;
  164. int i;
  165. b_array_ptr b_array_dest;
  166. u_array_ptr u_array_dest;
  167.  
  168. void test_pointer_subtraction ()
  169. {
  170.   i = & u_array_src - & b_array_src;            /* ERROR */
  171.   i = & b_array_src - & u_array_src;            /* ERROR */
  172.  
  173.   i = u_array_dest - b_array_dest;              /* ERROR */
  174.   i = b_array_dest - u_array_dest;              /* ERROR */
  175. }
  176.  
  177. int u_array_src[20] = { 0 };    /* complete its type */
  178. -----------------------------------------------------------------------------
  179. #13)  GCC fails to issue errors for the following invalid C code involving
  180.       invalid null pointer constants, even when the -pedantic-errors option
  181.       is used.  (GCC also fails to properly flag these kinds of invalid
  182.       null pointer constants in other contexts as well.)
  183.  
  184. int (*fp) ();
  185. void test () { fp = (void *) (void *) 0; }    /* ERROR */
  186. -----------------------------------------------------------------------------
  187. #14)  GCC fails to issue errors for the following invalid C code involving
  188.       invalid pointer type conversions, even when the -pedantic-errors option
  189.       is used.
  190.  
  191. struct incomp1; /* never completed */
  192. struct incomp2; /* completed towards the end - may make a difference */
  193.  
  194. typedef int             *p_to_object_type;
  195. typedef struct incomp1  *p_to_incomp1_type;
  196. typedef struct incomp2  *p_to_incomp2_type;
  197. typedef int             (*p_to_func_type) ();
  198.  
  199. p_to_object_type        p_to_object_value;
  200. p_to_incomp1_type       p_to_incomp1_value;
  201. p_to_incomp2_type       p_to_incomp2_value;
  202. p_to_func_type          p_to_func_value;
  203.  
  204. void
  205. test ()
  206. {
  207.   p_to_func_value = (p_to_func_type) p_to_object_value;         /* ERROR */
  208.   p_to_func_value = (p_to_func_type) p_to_incomp1_value;        /* ERROR */
  209.   p_to_func_value = (p_to_func_type) p_to_incomp2_value;        /* ERROR */
  210. }
  211.  
  212. struct incomp2 { int i; };
  213. -----------------------------------------------------------------------------
  214. #15)  GCC fails to issue errors for the following invalid C code involving
  215.       invalid pointer type conversions, even when the -pedantic-errors option
  216.       is used.
  217.  
  218. struct incomp1; /* never completed */
  219. struct incomp2; /* completed towards the end - may make a difference */
  220.  
  221. typedef int             *p_to_object_type;
  222. typedef struct incomp1  *p_to_incomp1_type;
  223. typedef struct incomp2  *p_to_incomp2_type;
  224. typedef int             (*p_to_func_type) ();
  225.  
  226. p_to_object_type        p_to_object_value;
  227. p_to_incomp1_type       p_to_incomp1_value;
  228. p_to_incomp2_type       p_to_incomp2_value;
  229. p_to_func_type          p_to_func_value;
  230.  
  231. void
  232. test ()
  233. {
  234.   p_to_object_value = (p_to_object_type) p_to_func_value;       /* ERROR */
  235.   p_to_incomp1_value = (p_to_incomp1_type) p_to_func_value;     /* ERROR */
  236.   p_to_incomp2_value = (p_to_incomp2_type) p_to_func_value;     /* ERROR */
  237. }
  238.  
  239. struct incomp2 { int i; };
  240. -----------------------------------------------------------------------------
  241. #16)  GCC fails to issue errors for the following invalid C code involving
  242.       local redeclarations of objects, even when the -pedantic-errors option
  243.       is used.
  244.  
  245. static int object_decl_6;
  246. static int object_defn_6 = 0;
  247.  
  248. void
  249. test ()
  250. {
  251.     extern double object_decl_6;                /* ERROR */
  252.     extern double object_defn_6;                /* ERROR */
  253. }
  254. -----------------------------------------------------------------------------
  255. #17)  GCC fails to issue errors for the following invalid C code involving
  256.       incompatible redeclarations, even when the -pedantic-errors option
  257.       is used.
  258.  
  259. void callee (char c);
  260. void foobar () { void callee(); }     /* ERROR */
  261. void callee (char c) { }
  262. -----------------------------------------------------------------------------
  263. #18)  GCC incorrectly issues an error for the following standard-conformant
  264.       ANSI C code when the -pedantic-errors option is used.
  265.  
  266. extern const int func_1 ();
  267. -----------------------------------------------------------------------------
  268. #19)  GCC fails to issue an error for the following pair of incompatible
  269.       function declarations, even when the -pedantic-errors option is used.
  270.  
  271. extern const int func_4 ();
  272. extern int func_4 ();                   /* ERROR */
  273. -----------------------------------------------------------------------------
  274. #20)  GCC incorrectly issues errors for the following standard-conformant
  275.       ANSI C code when the -pedantic-errors option is used.
  276.  
  277. static enum E1 { red, green, blue};
  278. static struct S1 { int member; };
  279. static union U2 { int member; };
  280.  
  281. void foobar ()
  282. {
  283.     auto enum E2 { red, green, blue };
  284.     auto struct S2 { int member; };
  285.     auto union U2 { int member; };
  286. }
  287. -----------------------------------------------------------------------------
  288. -- 
  289.  
  290. // Ron ("Loose Cannon") Guilmette    uucp: ...uunet!lupine!segfault!rfg
  291. //
  292. //      "On the one hand I knew that programs could have a compelling
  293. //       and deep logical beauty, on the other hand I was forced to
  294. //       admit that most programs are presented in a way fit for
  295. //       mechanical execution, but even if of any beauty at all,
  296. //       totally unfit for human appreciation."
  297. //                                              -- Edsger W. Dijkstra
  298.  
  299.