Posted by: gidilat August 4, 2005
Login in to Rate this Post:
0
?
![](/wysiwyg/editor/images/smiley/msn/thumbs_up.gif)
![10 more flags than likes deactivates post.](/wysiwyg/editor/images/smiley/msn/thumbs_down.gif)
My apologies to testdirector.
The standard says modification of string literal is undefined. Remember that 'undefined' does not equal to 'not allowed'. GNU C does not allow it. Others might and IMHO those that do are stupid.
This is what I found:
The standard says [6.1.4], "If the program attempts to modify [a string literal], the behavior is undefined."
and
3.16 undefined behavior: Behavior, upon use of a nonportable or
erroneous program construct, or erroneous data, or of indeterminately
valued objects, for which this International Standard imposes no
requirements. Permissible undefined behavior ranges from ignoring
the situation completely with unpredictable results, to behaving during
translation or program execution in a documented manner characteristic
of the environment (with or without the issuance of a diagnostic
method), to terminating a translation or execution (with the issuance
of a diagnostic message).
and
4 Compliance
A strictly conforming program shall ... not produce output
dependent on any unspecified, undefined, or implementation-defined
behavior, ...
... A conforming hosted implementation shall accept any strictly
conforming program.