1 struct ture {
2 int a;
3 };
4 struct cont {
5 struct ture *x;
6 };
7
8 struct ture *x;
9 struct ture **px;
10 struct cont *y;
11 void func (void)
12 {
13 int *a = &(x->a);
14 int *b = &x->a;
15 int *c = &(y->x->a);
16 int *d = &((*px)->a);
17
18 if (x)
19 frob();
20 if (px)
21 frob();
22 if (y->x)
23 frob();
24 if (y)
25 frob();
26
27 return;
28 }
29 /*
30 * check-name: Dereferencing before check
31 * check-command: smatch sm_deref_check_deref.c
32 *
33 * check-output-start
34 sm_deref_check_deref.c:20 func() warn: variable dereferenced before check 'px' (see line 16)
35 sm_deref_check_deref.c:24 func() warn: variable dereferenced before check 'y' (see line 15)
36 * check-output-end
37 */