[cfe-dev] Bug: Unexpected dereference claim on --analyze

Jan Engelhardt jengelh at medozas.de
Fri Dec 2 13:37:03 PST 2011



Observed output:
===
clang-case2.c:17:11: warning: Access to field 'child' results in a dereference
      of a null pointer (loaded from field 'root')
        t->root->child = 0;
           ~~~~  ^
1 warning generated.


Expected output:
===
None. There is no way to say with absolute confidence that t->root is
always NULL or never NULL.


Testcase:
===
/*
SUSE Linux clang version 3.0 (branches/release_30 142912) (based on LLVM 3.0)

clang --analyze this
*/
struct node {
	struct node *child;
};
struct tree {
	struct node *root;
};
static void add(struct tree *t)
{
#if 1 /* generate warning */
	t->root != 0;
#endif
	t->root->child = 0;
}



More information about the cfe-dev mailing list