Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Re: memcopy, memmove Implementation

Thread Tools

Re: memcopy, memmove Implementation

Micah Cowan
Posts: n/a
Richard Heathfield <(E-Mail Removed)> writes:

> Dan Pop wrote:
> >
> > In <(E-Mail Removed)> Micah Cowan <(E-Mail Removed)> 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.

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Memmove v/s Linked list Implementation C Programming 15 02-01-2007 12:31 PM
memcpy verses memmove C++ 2 02-14-2005 02:48 AM
Re: memcopy, memmove Implementation Trewth Seeker C Programming 0 07-14-2003 05:17 PM
Re: memcopy, memmove Implementation Dan Pop C Programming 1 06-24-2003 01:42 PM
Re: memcopy, memmove Implementation Dan Pop C Programming 0 06-24-2003 12:17 PM