[cfe-dev] uncovered path (wrong constraint?)

Jordan Rose jordan_rose at apple.com
Mon Apr 15 09:45:52 PDT 2013


Did you mean *(s++)!=0? The way you wrote this loop, 's' doesn't change, so either you skip over the loop or it becomes an infinite loop.

(Infinite loops would be another nice thing for the analyzer to catch but there are of course reasons why it is tricky.)

Jordan


On Apr 15, 2013, at 0:11 , YuvalShahar <yuval.shahar.007 at gmail.com> wrote:

> I clang the following code, but the expected warning is missing.
> Could it be that i is being constrained to zero, and this constraint is not
> being removed by the while statement? 
> 
> void use(int);
> 
> void checkchecker(char *s) {
> 	int i=0;
> 	int j;
> 	while(*s!=0) {
> 		i++;
> 	}
> 	if(i>0) {
> 		use(j);  // expected warning: Function call argument is an uninitialized
> value
> 	}
> }
> 
> If I change the if-predicate to "i==0", the warning is being reported.
> 
> Thanks, Yuval.
> 
> 
> 
> 
> --
> View this message in context: http://clang-developers.42468.n3.nabble.com/uncovered-path-wrong-constraint-tp4031492.html
> Sent from the Clang Developers mailing list archive at Nabble.com.
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev




More information about the cfe-dev mailing list