Posted by: testdirector August 3, 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)
GCC compiler, it crashes - one point to you.
Try MSDEV.EXE in XP. I did. it works just fine.
I'd like you to also try
const char *p = "abcde";
and other examples here in this thread.
I still let you analyze the result.
Which compiler you trust more? GCC or MSDEV.EXE?
And where has K&R said that "abcde" has to be protected? It is the GCC compiler which decided to put it in the read-only (.text??) section and you got the fault. There is an oversight on part of the GCC by doing just that. I let you find it.
The two statements
char *p = "abcde";
const char *p = "abcde";
should speak volume about the differences. The second one explicitly tells the compiler that content should be protected, I agree in this hands-down.