linux-gcc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Are string literals _always_ allocated in the RO section?
@ 2005-01-15 21:22 Denis Zaitsev
  2005-01-15 21:27 ` Dale Johannesen
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Denis Zaitsev @ 2005-01-15 21:22 UTC (permalink / raw)
  To: gcc, linux-gcc

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?

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2005-01-17 17:18 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-01-15 21:22 Are string literals _always_ allocated in the RO section? Denis Zaitsev
2005-01-15 21:27 ` Dale Johannesen
2005-01-15 21:41 ` Denis Zaitsev
2005-01-15 23:18 ` Gabriel Dos Reis
2005-01-17 17:18   ` Jan-Benedict Glaw

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).