-
Notifications
You must be signed in to change notification settings - Fork 75
Expand file tree
/
Copy pathtest.c
More file actions
31 lines (28 loc) · 883 Bytes
/
test.c
File metadata and controls
31 lines (28 loc) · 883 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <stddef.h>
struct s1 {
int v1, v2, v3;
};
void f2(int p1, int p2) {
int *v1;
v1 += p1; // NON_COMPLIANT
v1 += p2; // COMPLIANT
}
void f1() {
int v1[10];
struct s1 *v2;
size_t offset = offsetof(struct s1, v2);
size_t size = sizeof(v1);
int *v3 = (int *)(v2 + offset); // NON_COMPLIANT
char *v4 = (char *)v2 + offset; // COMPLIANT
v3 = (int *)(((char *)v2) + offset); // COMPLIANT
v2++; // COMPLIANT
v2 += 10; // COMPLIANT
v3 += size; // NON_COMPLIANT
v3++; // COMPLIANT
v3 += sizeof(v1); // NON_COMPLIANT
(void)v1[sizeof(v1) / sizeof(v1[0])]; // COMPLIANT
(void)v1[10 / sizeof(v1)]; // NON_COMPLIANT
v4 += offset; // COMPLIANT
f2(offset, 2);
}
//