home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / std / c / 3291 < prev    next >
Encoding:
Internet Message Format  |  1992-12-30  |  6.5 KB

  1. Path: sparky!uunet!crdgw1!rdsunx.crd.ge.com!bart!volpe
  2. From: volpe@bart.NoSubdomain.NoDomain (Christopher R Volpe)
  3. Newsgroups: comp.std.c
  4. Subject: Re: Standard conformance and GCC 2.3.3
  5. Message-ID: <1992Dec30.173634.15487@crd.ge.com>
  6. Date: 30 Dec 92 17:36:34 GMT
  7. References: <1992Dec30.011211.11409@netcom.com> <C02I8I.58I@jrd.dec.com>
  8. Sender: volpe@bart (Christopher R Volpe)
  9. Reply-To: volpe@ausable.crd.ge.com
  10. Organization: GE Corporate Research & Development
  11. Lines: 133
  12. Nntp-Posting-Host: bart.crd.ge.com
  13.  
  14. In article <C02I8I.58I@jrd.dec.com>, diamond@jit533.jit.dec.com (Norman Diamond) writes:
  15. |> In article <1992Dec30.011211.11409@netcom.com> rfg@netcom.com (Ronald F. Guilmette) writes:
  16. |> >-----------------------------------------------------------------------------
  17. |> >#7)  When compiling an empty source file while the -pedantic-errors option
  18. |> >     is in effect, GCC will generate an error message for a line number which
  19. |> >     does not actually exist in the source file.
  20. |> 
  21. |> I believe that diagnostics are allowed to contain spurious line numbers unless
  22.  
  23. I believe the diagnostics are allowed to say anything they want, and need not
  24. even supply a line number. However, I don't understand the "unless they follow
  25. a #line directive" part. Where does this come from?
  26.  
  27. |> they follow a #line directive.  (And of course a #line directive is allowed to
  28. |> command similar garbage.)
  29. |> >-----------------------------------------------------------------------------
  30. |> >#8)  GCC [-pedantic-errors] fails to issue errors for the following
  31. |> >void test_0 (char);
  32. |> >void test_0 (c) char c; { }
  33. |> 
  34. |> Again (as in #1) I see no violation of a constraint.
  35.  
  36. This is not the same as #1, and there is a constraint violation here:
  37.  
  38. Section 3.5 "All declarations in the SAME SCOPE [emphasis mine] that
  39. refer to the same object or function shall specify compatible types."
  40. These two declarations are in the same scope, whereas in #1, the scope
  41. of the declaration ended before the definition.
  42.  
  43. |> >-----------------------------------------------------------------------------
  44. |> >#9)  GCC fails to issue errors in cases where a static function is referenced
  45. |> >     but never defined, even when the -pedantic-errors option is used.
  46. |> >static void s (); int main () { s (); return 1; }
  47. |> 
  48. |> Again I see no violation of a constraint.  Furthermore, if you returned
  49.  
  50. Me neither, but...
  51.  
  52. |> EXIT_SUCCESS instead of 1, I believe it would be strictly conforming.
  53. |> Hard to believe, isn't it?  My best guess is that the invocation of s()
  54. |> acts as a no-op.  The standard doesn't seem to permit any other behavior.
  55.  
  56. Yeah, very hard to believe. Are you saying that all undefined functions must
  57. behave as no-ops? Or is there something special about undefined static 
  58. functions?
  59.  
  60. |> >-----------------------------------------------------------------------------
  61. |> >#10)  GCC [-pedantic-errors] fails to issue an error for the following invalid
  62. |> >void (*func_ptr) ();
  63. |> >int i;
  64. |> >void test () { func_ptr = i ? 0 : 0; }         /* ERROR */
  65. |> 
  66. |> The code looks valid to me.  The conditional expression  i ? 0 : 0  is an
  67. |> integral constant expression with value 0.  Null pointer constants can be
  68. |> assigned to function pointers.  (I expect no debate on this one.)
  69.  
  70. I'd like to debate you on this one, if I may. :-). Section 3.4 says,
  71. "An integral constant expression ... shall only have operands that are
  72. integer constants [and other types of obviously constant stuff]". The "i"
  73. used as the first operand of the conditional operator does not qualify, 
  74. regardless of the fact that its value does not affect the value of the
  75. expression as a whole.
  76.  
  77. |> >-----------------------------------------------------------------------------
  78. |> >#11)  GCC fails to issue errors for the following invalid C code involving
  79. |> >      comparison operators, even when the -pedantic-errors option is used.
  80. |> [Much editing by N.D.]
  81. |>  int b_array_src[3];
  82. |>  extern int u_array_src[];
  83. |> >int i;
  84. |> >void test_relational_operators () {
  85. |> >  i = & u_array_src > & b_array_src;            /* ERROR */
  86. |> >}
  87. |> >int u_array_src[20] = { 0 };    /* complete its type */
  88. |> 
  89. |> Hmm, we agree that GCC failed to conform this time, but I find the constraints
  90. |> for this very odd.  I wonder why there wasn't one allowance for "both operands
  91. |> are pointers to qualified or unqualified versions of compatible object or
  92. |> incomplete types."  The semantics could handle it without further adjustment.
  93.  
  94. Yes, I wondered the same thing when I looked it up.
  95.  
  96. |> >-----------------------------------------------------------------------------
  97. |> >#12)  GCC fails to issue errors for the following invalid C code involving
  98. |> >      the binary `-' operator, even when the -pedantic-errors option is used.
  99. |> [Declarations similar to #11.]
  100. |> >  i = & u_array_src - & b_array_src;            /* ERROR */
  101. |> 
  102. |> A more serious problem.  Again, we agree that GCC failed to conform.
  103.  
  104. Why is this one more serious?
  105.  
  106. |> >-----------------------------------------------------------------------------
  107. |> >#19)  GCC fails to issue an error for the following pair of incompatible
  108. |> >      function declarations, even when the -pedantic-errors option is used.
  109. |> >extern const int func_4 ();
  110. |> >extern int func_4 ();                   /* ERROR */
  111. |> 
  112. |> For the fourth time, this does not violate a constraint.
  113.  
  114. Yes it does. Sections 3.5.3 and 3.5.4.3 indicate that the two declarations
  115. are not compatible, and the constraint in 3.5 says that they must be
  116. compatible if they are in the same scope.
  117.  
  118. |> >-----------------------------------------------------------------------------
  119. |> >#20)  GCC incorrectly issues errors for the following standard-conformant
  120. |> >      ANSI C code when the -pedantic-errors option is used.
  121. |> >static enum E1 { red, green, blue};
  122. |> >static struct S1 { int member; };
  123. |> >static union U2 { int member; };
  124. |> >void foobar () {
  125. |> >    auto enum E2 { red, green, blue };
  126. |> >    auto struct S2 { int member; };
  127. |> >    auto union U2 { int member; };
  128. |> >}
  129. |> 
  130. |> Spurious diagnostics are allowed, though now they return to the status of
  131. |> unfriendly and misleading.  What happened when you tried executing it?
  132.  
  133. These diagnostics are prefectly friendly and very helpful. Since the
  134. declarations allocate no storage (there's no object being defined), a 
  135. storage class specifier is useless and superfluous.
  136.  
  137. |> --
  138. |> Norman Diamond                diamond@jit.dec.com
  139. |> If this were the company's opinion, I wouldn't be allowed to post it.
  140. |> Pardon me?  Or do I have to commit a crime first?
  141.  
  142. -- 
  143. ==================
  144. Chris Volpe
  145. G.E. Corporate R&D
  146. volpecr@crd.ge.com
  147.