This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Are string literals _always_ allocated in the RO section?
- From: Gabriel Dos Reis <gdr at integrable-solutions dot net>
- To: Denis Zaitsev <zzz at anda dot ru>
- Cc: gcc at gcc dot gnu dot org, linux-gcc at vger dot kernel dot org
- Date: 16 Jan 2005 00:18:20 +0100
- Subject: Re: Are string literals _always_ allocated in the RO section?
- Organization: Integrable Solutions
- References: <20050116022247.A3066@natasha.ward.six>
Denis Zaitsev <zzz@anda.ru> 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