Path: utzoo!attcan!uunet!husc6!ukma!uflorida!novavax!proxftl!bill From: bill@proxftl.UUCP (T. William Wells) Newsgroups: comp.lang.c Subject: Re: const comparison in C and C++ Message-ID: <785@proxftl.UUCP> Date: 18 Sep 88 10:32:01 GMT References: <709@paris.ICS.UCI.EDU> <8500@smoke.ARPA> <1411@solo3.cs.vu.nl> <8516@smoke.ARPA> Reply-To: bill@proxftl.UUCP (T. William Wells) Organization: Proximity Technology, Ft. Lauderdale Lines: 21 Summary: Expires: Sender: Followup-To: Distribution: Keywords: In article <8516@smoke.ARPA> gwyn@brl.arpa (Doug Gwyn (VLD/VMB)) writes: : C "const" basically constrains the means of access, so that for example : void copy(const char *source, char *destination, unsigned count); : is a useful declaration for a function that is guaranteed not to alter : storage via its first parameter. However, assuming this represents a : block-move function, the destination range is allowed to overlap the : source range, because modification of any storage validly accessible via : the second parameter is NOT prohibited. Sorry Doug, it's undefined. (And, drat, I get to fix a, guess what, COPY FUNCTION, where I made this same mistake. :-) From section 3.5.3: "If an attempt is made to modify an object defined with a const-qualified type through use of an lvalue with non-const-qualified type, the behavior is undefined." --- Bill novavax!proxftl!bill