[splint-discuss] How does splint check a pointer to constant
Jorge Peixoto de Morais Neto
please.no.spam.here at gmail.com
Tue Mar 6 07:52:13 PST 2007
When I feed the program
#include <stdlib.h>
int main(void){
/*@unused@*/ const char *p="a";
/*@unused@*/ char *x=p;
return EXIT_SUCCESS;
}
to splint +checks, it gives me no warning. But when I compile it with gcc, I
am warned that
"test.c:5: warning: initialization discards qualifiers from pointer target
type".
However, when I feed to splint the program
#include <stdlib.h>
int main(void){
/*@unused@*/ char const * const teststringarray[]={"a"};
return EXIT_SUCCESS;
}
, splint warns me that
test.c: (in function main)
test.c:3:54: Read-only string literal storage used as initial value for
unqualified storage: teststringarray[0] = "a"
A read-only string literal is assigned to a non-observer reference. (Use
-readonlytrans to inhibit warning)
, while gcc warns me of nothing (except that the variable teststringarray is
unused).
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.
Thanks in advance.
--
Software is like sex: it is better when it is free.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.cs.Virginia.EDU/pipermail/splint-discuss/attachments/20070306/e214241b/attachment.htm
More information about the splint-discuss
mailing list