Re: Are string literals _always_ allocated in the RO section?

Gabriel Dos Reis <[email protected]>
Newsgroups gmane.comp.gcc.devel,gmane.linux.gcc
Organization Integrable Solutions
Message-ID <[email protected]>
Denis Zaitsev <[email protected]> writes:

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

In the program? Yes.

-- Gaby
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.