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:40:06 -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 #5 from vda dot linux at googlemail dot com 2007-01-28 17:40 -------
http://david.tribble.com/text/cdiffs.htm#C99-string-const
"In C, string literals have type char[n], but are not modifiable (i.e.,
attempting to modify the contents of a string literal is undefined behavior)."
In light of this, char msg[] = "wow" starts to look "strange". Oh well. If the
definition above is really what C99 says (I am not an C99 expert), maybe a
warning would be in order for such code?
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30622