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