Skip to content

Commit d3d56d1

Browse files
committed
add new test case
1 parent d29014e commit d3d56d1

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

tests/regression/86-relational-array-oob/04-global2.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// PARAM: --enable ana.arrayoob --enable ana.int.interval --set ana.activated[+] apron --disable warn.integer --set ana.apron.domain polyhedra
1+
// PARAM: --enable ana.arrayoob --enable ana.int.interval --set ana.activated[+] apron --disable warn.integer
22

33
int f(char ptr[], unsigned len)
44
{
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// SKIP PARAM: --enable ana.arrayoob --enable ana.int.interval --set ana.activated[+] apron --disable warn.integer
2+
// This file contains known limitations of the current relational array out-of-bounds analysis.
3+
int f(char ptr[], unsigned len)
4+
{
5+
for (unsigned int i = 0; i < len; i++)
6+
{
7+
// due to the pointer arithmetic, the index expressions for these are `(ptr + i) - ptr` and `(ptr + i - 1U) - ptr` respectively
8+
// We therefore fail to evalulate if this is smaller than our ghost variable
9+
ptr[i] = 42; // WARN
10+
ptr[i - 1] = 42; // TODO NOWARN
11+
}
12+
}
13+
14+
int main()
15+
{
16+
unsigned int len;
17+
unsigned int top;
18+
19+
if (top)
20+
len = 5;
21+
else
22+
len = 10;
23+
24+
char ptr[len];
25+
f(ptr + 1, len);
26+
27+
char *ptr2 = ptr + 2;
28+
for (unsigned int i = 0; i < len; i++)
29+
{
30+
char s = ptr2[i - 1]; // TODO NOWARN the index expression for this is "any_index"
31+
}
32+
}

0 commit comments

Comments
 (0)