When I feed the program <br><br>#include <stdlib.h><br>int main(void){<br><br> /*@unused@*/ const char *p="a";<br> /*@unused@*/ char *x=p;<br> return EXIT_SUCCESS;<br>}<br clear="all"><br>to splint +checks, it gives me no warning. But when I compile it with gcc, I am warned that
<br><br>"test.c:5: warning: initialization discards qualifiers from pointer target type".<br><br>However, when I feed to splint the program <br><br>#include <stdlib.h><br>int main(void){<br> /*@unused@*/ char const * const teststringarray[]={"a"};
<br> return EXIT_SUCCESS;<br>}<br>, splint warns me that <br><br>test.c: (in function main)<br>test.c:3:54: Read-only string literal storage used as initial value for<br> unqualified storage: teststringarray[0] = "a"
<br> A read-only string literal is assigned to a non-observer reference. (Use<br> -readonlytrans to inhibit warning)<br><br>, while gcc warns me of nothing (except that the variable teststringarray is unused). <br><br>The behavior in the program is bugging me (I have similar case in a real program). Why does this happen? There is nothing wrong or suspect in initializing with a string literal an array of const pointers to constants (const * const) How can I fix this? In the manual, I only found something about /*@observer@*/, but this seems absurd, since I am not dealing with an abstract type.
<br><br>Thanks in advance.<br><br>-- <br>Software is like sex: it is better when it is free.