This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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



On Jan 15, 2005, at 1:22 PM, Denis Zaitsev wrote:


This program:

void x(char *s)
{
    *s= 'x';
}

main()
{
    x("y");
}

is compiled plainly but cathes SIGSEGV in the

*s= 'x'

line.

That's what's supposed to happen. Storing into a string constant is invalid C.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]