On 1/6/10 10:31 PM, Myles Watson wrote:
arg, that kind of error is almost embarassing :-)
This seems like something that could have easily been caught by static analysis, but I can't find a compiler warning that would have caught it.
Could scan-build have caught it (I looked and didn't find it in the output)? Other tools?
scan-build does not catch it (as of r92410)
Here's a simple test case if someone wants to try other tools:
#include <stdio.h> const char *func_foo(void) { const char *foo="foobar\n"; return foo; } int main(void) { const char *foo;
foo = func_foo(); printf("%s\n", foo); return 0; }
sparse says: test.c:2:12: warning: symbol 'func_foo' was not declared. Should it be static? which could indicate it catches the error, not sure.
Stefan