------- Comment #4 from pinskia at gcc dot gnu dot org 2007-01-28 17:31 ------- (In reply to comment #3) > 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.
They are still considered constant even though the type decays to char*. The reason why the type of a string literal decays to char* is because before C90/C89, const did not exist so the C standards committee wantted to support older code. Anyways if you want a warning use -Wwrite-strings. -- pinskia at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution| |INVALID http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30622