Re: memcopy, memmove Implementation

Discussion in 'C Programming' started by Micah Cowan, Jun 26, 2003.

  1. Micah Cowan

    Micah Cowan Guest

    Richard Heathfield <> writes:

    > Dan Pop wrote:
    > >
    > > In <> Micah Cowan <> 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
     
    Micah Cowan, Jun 26, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dan Pop

    Re: memcopy, memmove Implementation

    Dan Pop, Jun 24, 2003, in forum: C Programming
    Replies:
    0
    Views:
    1,249
    Dan Pop
    Jun 24, 2003
  2. Dan Pop

    Re: memcopy, memmove Implementation

    Dan Pop, Jun 24, 2003, in forum: C Programming
    Replies:
    1
    Views:
    2,532
  3. Trewth Seeker

    Re: memcopy, memmove Implementation

    Trewth Seeker, Jul 14, 2003, in forum: C Programming
    Replies:
    0
    Views:
    536
    Trewth Seeker
    Jul 14, 2003
  4. Replies:
    15
    Views:
    668
    Jorgen Grahn
    Feb 1, 2007
  5. JeanDean
    Replies:
    2
    Views:
    346
    Grizlyk
    Feb 13, 2007
Loading...

Share This Page