This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/30622] char *p; p = "str"; puts "str" into rodata
- From: "vda dot linux at googlemail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 28 Jan 2007 17:25:27 -0000
- Subject: [Bug c/30622] char *p; p = "str"; puts "str" into rodata
- References: <bug-30622-12956@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #3 from vda dot linux at googlemail dot com 2007-01-28 17:25 -------
Sorry! Bug in the testcase, should be "char *p".
I remember that string literals are special - they decay to "const char *" OR
to "char*" depending on context. In this context, it should decay to "char*",
and it does - gcc doesn't complain "assingment of const to non-const", the bug
is that gcc placed "str" in ro section.
char *p;
int main() {
p = "str";
return 0;
}
/*
.file "t.c"
.section .rodata.str1.1,"aMS",@progbits,1
.LC0:
.string "str"
.text
.globl main
.type main, @function
main:
pushl %ebp
movl %esp, %ebp
movl $.LC0, p
xorl %eax, %eax
leave
ret
.size main, .-main
.comm p,4,4
.ident "GCC: (GNU) 4.1.1"
.section .note.GNU-stack,"",@progbits
*/
--
vda dot linux at googlemail dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |UNCONFIRMED
Resolution|INVALID |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30622