home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / lang / c / 11786 < prev    next >
Encoding:
Text File  |  1992-07-30  |  2.3 KB  |  52 lines

  1. Newsgroups: comp.lang.c
  2. Path: sparky!uunet!snorkelwacker.mit.edu!bloom-picayune.mit.edu!news
  3. From: scs@adam.mit.edu (Steve Summit)
  4. Subject: Re: Variable length records
  5. Message-ID: <1992Jul30.203126.24344@athena.mit.edu>
  6. Sender: news@athena.mit.edu (News system)
  7. Nntp-Posting-Host: adam.mit.edu
  8. Organization: none, at the moment
  9. References: <1992Jul29.160618.27224@klaava.Helsinki.FI> <156nvcINNecv@early-bird.think.com> <1992Jul30.002228.5973@klaava.Helsinki.FI>
  10. Date: Thu, 30 Jul 1992 20:31:26 GMT
  11. Lines: 39
  12.  
  13. In article <1992Jul30.002228.5973@klaava.Helsinki.FI>, wirzeniu@klaava.Helsinki.FI (Lars Wirzenius) writes:
  14. > On the other hand, perhaps this thread is getting a bit too long: if you
  15. > want strict conformance and portability, use a separately allocated
  16. > array, if you prefer a little bit of convenience, use the others.  And
  17. > the '[1]' version (see earlier posts) may even have both qualities (I'm
  18. > not quite certain).
  19.  
  20. It does.  As the comp.lang.c frequently-asked questions (FAQ)
  21. list says,
  22.  
  23.     This technique is popular, although Dennis Ritchie has called it
  24.     "unwarranted chumminess with the compiler."  The ANSI C standard
  25.     allows it only implicitly.  It seems to be portable to all known
  26.     implementations.  (Compilers which check array bounds carefully
  27.     might issue warnings.)
  28.  
  29.     References: ANSI Rationale Sec. 3.5.4.2 pp. 54-5.
  30.  
  31. I wish it were possible to state unambiguously that the usage is
  32. strictly conforming, and to point at a single statement in the
  33. Standard to support the claim.  I know of at least one satisfying
  34. "proof" (due to Mark Brader), but it's a bit involved.  (As the
  35. Jargon file says, "A language lawyer is distinguished by the
  36. ability to show you the five sentences scattered through a
  37. 200-plus-page manual that together imply the answer to your
  38. question `if only you had thought to look there'.")
  39.  
  40. Without question, the "chummy" idioms are so widespread that most
  41. compilers would probably strive to support them even if they were
  42. not quite Standard.
  43.  
  44. Actually, if you're willing to trust the Rationale (which is, of
  45. course, "not part of American National Standard X3.159-1989," the
  46. section referenced in the above FAQ list entry is quite direct in
  47. stating that such variable-size structures are permissible, as
  48. long as the declared array size is greater than 0.
  49.  
  50.                     Steve Summit
  51.                     scs@adam.mit.edu
  52.