home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / std / c / 2561 < prev    next >
Encoding:
Internet Message Format  |  1992-09-02  |  2.6 KB

  1. Path: sparky!uunet!cis.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!ucbvax!jit081.enet.dec.com!diamond
  2. From: diamond@jit081.enet.dec.com (03-Sep-1992 1325)
  3. Newsgroups: comp.std.c
  4. Subject: Re: strcpy implementation question
  5. Message-ID: <9209030426.AA24169@enet-gw.pa.dec.com>
  6. Date: 3 Sep 92 04:26:37 GMT
  7. Sender: daemon@ucbvax.BERKELEY.EDU
  8. Lines: 47
  9.  
  10. In article <PINKAS.92Sep2173635@skywalker.intel.com> pinkas@skywalker.intel.com (Israel Pinkas) writes:
  11. >My understanding is that a routine is only allowed to have undocumented
  12. >side effects if they will have no effect on the execution of the program.
  13.  
  14. Sounds fair to me.
  15.  
  16. >In my book, if evaluating 1+2 launches missles, it would be OK as long as
  17. >(1) the missles did not destroy the currently executing computer, and (2)
  18. >the lack of a missle in the launch bay did not cause the program to abort:)
  19.  
  20. (1) isn't allowed to affect any other output of the program either  :-)
  21.  
  22. >The question still boils down to this:
  23. >Can the compiler consider the memory past the destination of a copy as
  24. >scratch memory, or does strcpy GUARANTEE only to modify the memory that is
  25. >necessary for copying the string?
  26.  
  27. How many times do you have to be told?  John Levine posted an example where
  28. the proposed side effect would cause an illegal difference.
  29.  
  30. For another example, the expression x+y is supposed to add two variables
  31. (if they have addable types) and is not supposed to zero out every other
  32. variable in the program.
  33.  
  34. If you would like an interpretation ruling to say "Operations that are
  35. defined by the standard shall not have other arbitrary side effects"
  36. then write to the committee requesting one.  If your employer decides to
  37. make the request as an official corporate concern, then it will probably
  38. even get the ruling (I personally think) rather than being laughed off.
  39.  
  40. [Regarding someone's faulty example of a variable length structure hack]
  41. >I don't know of a single compiler that guarantees to place two static
  42. >variables which are declared in the same file next to each other.
  43.  
  44. Yeah, that example was faulty.  I think you know how to construct a good one.
  45.  
  46. >The variable length struct is a hack.  There is nothing in the language
  47. >that prevents the compiler from performing bounds checking on accesses to
  48. >name.
  49.  
  50. Uh, nothing except the standard's definitions of [], unary *, and binary +
  51. operators.  :-R rhetoric.
  52. Bounds checking is not allowed to affect output of a valid but ugly program.
  53. --
  54. Norman Diamond       diamond@jit081.enet.dec.com
  55. If this were the company's opinion, I wouldn't be allowed to post it.
  56. "Yeah -- bad wiring.  That was probably it.  Very bad."
  57.