[splint-discuss] How does splint check a pointer to constant
CBFalconer
cbfalconer at yahoo.com
Fri Apr 6 21:54:22 PDT 2007
Jorge Peixoto de Morais Neto wrote:
>
... snip ...
>
> #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.
Add "-Wwrite-strings" to the gcc call, and it should warn you.
--
<http://www.cs.auckland.ac.nz/~pgut001/pubs/vista_cost.txt>
<http://www.securityfocus.com/columnists/423>
"A man who is right every time is not likely to do very much."
-- Francis Crick, co-discover of DNA
"There is nothing more amazing than stupidity in action."
-- Thomas Matthews
More information about the splint-discuss
mailing list