aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/validation/ptr-sub-blows.c
blob: af3d79e7c521d1f8a87a022caf303ec89259c60b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
static int ok(int *a, int *b)
{
	return a - b;
}

struct s {
	int a, b, c;
};

static int ko(struct s *a, struct s *b)
{
	return a - b;
}

/*
 * check-name: ptr-sub-blows
 * check-command: sparse -Wptr-subtraction-blows $file
 *
 * check-error-start
ptr-sub-blows.c:12:18: warning: potentially expensive pointer subtraction
ptr-sub-blows.c:12:18:     'struct s' has a non-power-of-2 size: 12
 * check-error-end
 */