Are string literals _always_ allocated in the RO section?
Denis Zaitsev <[email protected]> Sun, 16 Jan 2005 02:22:48 +0500
| Newsgroups | org.kernel.vger.linux-gcc |
|---|---|
| Message-ID | <[email protected]> |
This program:
void x(char *s)
{
*s= 'x';
}
main()
{
x("y");
}
is compiled plainly but cathes SIGSEGV in the
*s= 'x'
line. And it's because the string "y" is put in the .text section.
And the fact that the x()'s parm is explicitly declared as <char*>,
not <const char*> does nothing in this case. Should it be considered
as a bug?