This is the mail archive of the gcc-help@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: gcc 4.1.1: char *p = "str" puts "str" into rodata


[ off-topic for gcc; redirected to gcc-help ]

Denis Vlasenko writes:
 > char p;
 > int main() {
 >         p = "";
 >         return 0;
 > }

This is odd code: you're assigning a pointer to a string to a char
variable.

 > Don't you think that "" should end up in rw data?

No: it's a literal string.  Many, many years ago, C compilers put
literal strings into read/write memory and it was possible to alter
them, but C89 outlawed that practice.

Andrew.


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