const comparison in C and C++
Doug Gwyn
gwyn at smoke.ARPA
Mon Sep 19 12:28:44 AEST 1988
In article <785 at proxftl.UUCP> bill at proxftl.UUCP (T. William Wells) writes:
>In article <8516 at smoke.ARPA> gwyn at brl.arpa (Doug Gwyn (VLD/VMB) <gwyn>) writes:
>: void copy(const char *source, char *destination, unsigned count);
>: ... modification of any storage validly accessible via
>: the second parameter is NOT prohibited.
>Sorry Doug, it's undefined.
Sorry yourself, it's the way I stated.
>"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."
This is simply not relevant. The parameter declarations do not define
objects.
So long as the object being block-moved into does not have the "const"
attribute, it can be modified. The point is that a pointer-to-const
can ALSO be used to refer to such a non-const object, but it cannot be
used to modify the object.
More information about the Comp.lang.c
mailing list