|
![]() Click on image to see enlargment |
|
PC-lint/FlexeLint Output | Reference Manual Explanation | Home bug1776.cpp
A flower shop has a data base of all its flowers. In deleting an entry, the program appears to have created a strange hybrid, at least on one compiler. What's going on? bug1776.cpp lint Output
--- Module: bug1776.cpp
_
{ "daisy", 2, "rose", 0, "caledonia", 6, "pansy", 5, "lilac", 3 };
bug1776.cpp(5) : Info 1776: Converting a string literal to char * is not const
safe (initialization)
bug1776.cpp(5) : Info 1776: Converting a string literal to char * is not const
safe (initialization)
bug1776.cpp(5) : Info 1776: Converting a string literal to char * is not const
safe (initialization)
bug1776.cpp(5) : Info 1776: Converting a string literal to char * is not const
safe (initialization)
bug1776.cpp(5) : Info 1776: Converting a string literal to char * is not const
safe (initialization)
Reference Manual Explanation
1776 Converting a string literal to char * is not const safe
(Context) -- A string literal, according to Standard C++
is typed an array of const char. This message is issued
when such a literal is assigned to a non-const pointer.
For example:
char *p = "string";
will trigger this message. This pointer could then be
used to modify the string literal and that could produce
some very strange behavior.
Such an assignment is legal but "deprecated" by the C++
Standard. The reason for not ruling it illegal is that
numerous existing functions have their arguments typed as
char * and this would break working code.
Note that this message is only given for string literals.
If an expression is typed as pointer to const char in some
way other than via string literal, then an assignment of
that pointer to a non-const pointer will receive a more
severe warning.
If you have comments or questions about this bug, please post them to our Discussion Forum |
Previous Bug - Bug #514 - April 2005