On Saturday 16 August 2008, Frank Wallingford wrote:
> The compiler doesn't analyze the logic as well as you think it does. For
> example, there are no warnings here with gcc 4.1.2 using -Wuninitialized
> -O:
>
> int foo(int y)
> {
> int x;
> if (y == 1) x = 2;
> if (y == 2) return x;
> return 0;
> }
'splint' may do what you want (although understandably, it's extremely noisy).
I tried it on the above, and it complains that:
Splint 3.1.2 --- 01 May 2008
testprog.c: (in function foo)
testprog.c:7:23: Variable x used before definition
An rvalue is used that may not be initialized to a value on some execution
path. (Use -usedef to inhibit warning)
testprog.c:13:29: Parse Error. (For help on parse errors, see splint -help
parseerrors.)
*** Cannot continue.
And line 7 is "if (y == 2) return x;".
So at least Spint can test for and find that condition.
-- Chris
--
Chris Knadle
[EMAIL PROTECTED]
_______________________________________________
Mid-Hudson Valley Linux Users Group http://mhvlug.org
http://mhvlug.org/cgi-bin/mailman/listinfo/mhvlug
Upcoming Meetings (6pm - 8pm) MHVLS Auditorium
Jun 4 - Sqeak! and eToys
Jul 2 - KVM (Tenative)
Aug 6 - Zenos
Sep 3 - TBD