Re: why debug step by step, it s ok



Robert Gamble <rgamble99@xxxxxxxxx> writes:
> On Fri, 03 Jun 2005 17:12:39 +0200, Emmanuel Delahaye wrote:
[...]
>> strings are not mutable...
>
> Psst: string _literals_ are not mutable.

Psst: Attempting to modify a string literal invokes undefined
behavior. One way that undefined behavior can be manifested is that
the string literal can be modified.

Saying that string literals are not mutable could imply that it's an
error that the implementation will catch. It might, or it might not.
It's up to the programmer to avoid making the mistake in the first
place.

--
Keith Thompson (The_Other_Keith) kst-u@xxxxxxx <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
.



Relevant Pages

  • Re: why is this variable read-only
    ... If you are not allowed to do something, Undefined Behavior is often ... Some things that might happen if you attempt to modify the contents ... There is a silent change to similar string literals ... Your DS9000 starts World War IV before World War III. ...
    (comp.lang.c)
  • Re: pointer and storage
    ... I always thought that where the string literals are stored ... it invokes undefined behavior. ... pointer is unconditionally bad, ... "hello" is not const char *. ...
    (comp.lang.c)
  • Re: Compiler difference
    ... However, when I checked other examples of array and its size, they tend to ... Attempts to do so result in 'undefined behavior' ... Evalutating the value of this pointer will ... > String literals, by definition are not allowed to be ...
    (alt.comp.lang.learn.c-cpp)
  • Re: Reset a string?
    ... > you have no garanties you'll be able to modify it like you did.. ... it is undefined behavior. ... The C standard does not state that string literals are ...
    (comp.lang.c)
  • Re: why debug step by step, it s ok
    ... Attempting to modify a string literal invokes undefined ... "without invoking undefined behavior" part was implied and trying not ... > Saying that string literals are not mutable could imply that it's an ...
    (comp.lang.c)