Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C Programming (http://www.velocityreviews.com/forums/f42-c-programming.html)
-   -   Re: memcopy, memmove Implementation (http://www.velocityreviews.com/forums/t313828-re-memcopy-memmove-implementation.html)

Micah Cowan 06-26-2003 02:52 AM

Re: memcopy, memmove Implementation
 
Richard Heathfield <binary@eton.powernet.co.uk> writes:

> Dan Pop wrote:
> >
> > In <m3adc9xuts.fsf@localhost.localdomain> Micah Cowan <micah@cowan.name> writes:
> >

>
> <snip>
>
> > >An implementation could do anything it likes to stop you, or
> > >not stop you, from violating the const restriction. It is not merely a
> > >reminder to the programmer, but a hint to the compiler (or whatever)
> > >as well.

> >
> > It's a useless hint to the compiler: you can still use the pointer to
> > alter the object value (after casting away the const) and the behaviour
> > is well defined if the original object was not const qualified.

>
> A minor nit: that is incorrect if the original object is a string
> literal, since they are not const-qualified and yet modifying them
> invokes undefined behaviour.


Hm... I think Dan's point is that the const in the parameter decls is
a compiler hint. This may have been pete's point as well. I had
thought he was saying this about "const" in general (but then, I
walked in mid-thread...).

You could just as easily pass a string through a non-const char*
parameter, and modifying it would be just as undefined.

-Micah


All times are GMT. The time now is 06:26 PM.

Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57