xiw / stack

A static checker for identifying unstable code.
http://css.csail.mit.edu/stack/
Other
359 stars 56 forks source link

Variable is used while uninitialized #8

Closed hughescr closed 11 years ago

hughescr commented 11 years ago

This is probably not so good, in a tool which is supposed to check for exactly this kind of issue. The compiler catches it as a warning:

lglib.c:6896:7: warning: variable 'res' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized] if (abs (lgl->opts->bias.val) <= 1) { ^~~~~~~~~~ lglib.c:6967:10: note: uninitialized use occurs here return res; ^~~ lglib.c:6896:3: note: remove the 'if' if its condition is always false if (abs (lgl->opts->bias.val) <= 1) { ^~~~~~~~~ lglib.c:6886:16: note: initialize the variable 'res' to silence this warning int lidx, res, l4, r4, b4, l10, r10, b10, m, oldbias; ^ = 0

xiw commented 11 years ago

We turned off this intentionally since compilers are doing a good job about uninitialized variables. You can turn this on by changing STACK's script.

hughescr commented 11 years ago

Not sure what you mean by "we removed this". It's in the code now -- uninitialized variable warning. The warning can be removed easily, and the code corrected, by initializing "res" in the declaration line as suggested by clang, or if you want to leave it uninitalized by bracketing the offending code with a #pragma that turns off that warning for that particular occurrence. Either way, leaving the warnings in the code is likely to make people question your attention to sloppy code in a code-sloppiness detection tool.

xiw commented 11 years ago

Oops I misread your report. This is an issue in the Lingeling solver, which you should report upstream. Thanks.

xiw commented 11 years ago

Looks like the return value res is not used by its callee at all. I'm closing this issue.