home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / std / c / 3302 < prev    next >
Encoding:
Internet Message Format  |  1992-12-31  |  4.1 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: Maximum depth of #if preprocessing directives
  5. Message-ID: <1992Dec31.142213.21450@crd.ge.com>
  6. Date: 31 Dec 92 14:22:13 GMT
  7. References: <JET.92Dec24133237@boxer.nas.nasa.gov> <BzsK12.5Ky@jrd.dec.com> <1992Dec29.001933.25655@lucid.com> <C01q3x.Bpp@sneaky.lonestar.org> <1992Dec30.184909.23125@taumet.com>
  8. Sender: volpe@bart (Christopher R Volpe)
  9. Reply-To: volpe@ausable.crd.ge.com
  10. Organization: GE Corporate Research & Development
  11. Lines: 66
  12. Nntp-Posting-Host: bart.crd.ge.com
  13.  
  14. In article <1992Dec30.184909.23125@taumet.com>, steve@taumet.com 
  15. (Steve Clamage) gives several excellent arguments against including
  16. translation limits as part of a language standard.
  17.  
  18. I agree wholeheartedly with Steve. I would prefer to have all implementations
  19. be required to document their individual translation limits, and have any
  20. implementation-imposed translation limit be considered a bug. No 
  21. real implementation would be conforming, but implementations could be judged
  22. on how close they come to achieving conformance. As it stands, any compiler
  23. implementor can scream "translation limits!" whenever a bug is reported
  24. to them. In fact, according to the precise wording of the C Standard, 
  25. the following program is a valid ANSI C implementation:
  26.  
  27.     #/bin/csh
  28.     echo "Warning: Dumb-ass compiler"
  29.     echo "Program accepted."
  30.  
  31. Why is this a conforming implementation? Well, let's look at what the
  32. requirements of a conforming implementation are:
  33.  
  34. 1) Section 1.7 "Compliance" states that "A conforming hosted implementation
  35.    shall accept any strictly-conforming program" (followed by a slight
  36.    relaxation of this for conforming freestanding implementations). One 
  37.    might be tempted to define "accept" as "translate and execute", but
  38.    nowhere is "accept" defined this way, and, in fact, defining it this
  39.    way would cause the Standard to contradict itself later in 2.2.4.1.
  40.    So, I define "accept" as printing out "Program accepted". The above 
  41.    implementation meets this criteria for all strictly conforming programs
  42.    (as well as any other program, which is fine).
  43.  
  44. 2) Section 2.1.1.3 "Diagnostics" says, "A conforming implementation shall
  45.    produce at least one diagnostic message ... for every translation unit
  46.    that contains a violation of any syntax rule or constraint." The above
  47.    implementation meets this criteria. And, of course, spurious diagnostics
  48.    are allowed.
  49.  
  50. 3) Section 2.2.4.1 "Translation Limits" says, "The implementation shall be
  51.    able to translate and execute AT LEAST ONE program that contains AT LEAST
  52.    ONE instance of every one of the following limits" [emphasis mine] and
  53.    goes on to list the limits. This is the loophole you could pilot an
  54.    aircraft carrier through. Note that it DOESN'T say that it shall 
  55.    translate and execute any strictly conforming program that doesn't
  56.    exceed any of the limits. It simply must translate and execute AT LEAST
  57.    ONE program that meets them all. AND THE IMPLEMENTOR GETS TO CHOOSE
  58.    WHICH PROGRAM!!! For my above implementation, I can construct a strictly
  59.    conforming program that contains one instance of each of the translation
  60.    limits, but doesn't print anything out. So, it has no output. I feed it
  61.    to the above implementation (which I claim is an interpreter, and therefore
  62.    need not produce an executable file), which successfully translates and
  63.    executes it, producing no output other than the spurious diagnostic and
  64.    the acceptance indicator. Voila! Instant conformance.
  65.  
  66. Granted, no one is going to try to market such an implementation, but the
  67. problem is that no matter what "bug" you think you may have found in
  68. an implementation, you can't yell at the vendor claiming non-conformance
  69. because the implementor can say, "Well, yes, our compiler doesn't produce
  70. the correct output for YOUR program, but YOUR program isn't the one we
  71. claim our compiler successfully translates and executes as required by
  72. 2.2.4.1. Thanks for calling. Have a nice day."
  73.  
  74. -Chris
  75. -- 
  76. ==================
  77. Chris Volpe
  78. G.E. Corporate R&D
  79. volpecr@crd.ge.com
  80.