Re: why debug step by step, it s ok



Keith Thompson wrote:
> 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.

I thought about clarifying that but decided not to assuming that the
"without invoking undefined behavior" part was implied and trying not
to be too pedantic as I know what Emmanuel meant ;)

> 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.

I agree, bad decision on my part.

Robert Gamble

.



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: Question related to string functions
    ... is not terminated by '\0' it can show undefined behavior? ... array whose size is specified as exactly the length of the array, ... Character string literals that are adjacent ... not a special case of string literals. ...
    (comp.lang.c)