Skip to content

Commit 967afbb

Browse files
Test for union field sensitivity bug
The assignment to s becomes {-22} main::1::s!0@1#2 = main::1::u!0@1#0..x3[[3]] The field sensitivity variable on the rhs does not even exist as it is outside the array bounds of u.x3 (however still pointing to valid memory of the union). I have seen --pointer-check violations in other situations for similar reasons.
1 parent d05a097 commit 967afbb

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#include <assert.h>
2+
3+
union UNIONNAME
4+
{
5+
int x1;
6+
char x3[3];
7+
};
8+
9+
int main()
10+
{
11+
union UNIONNAME u;
12+
u.x1 = 0x01010101;
13+
14+
assert(u.x3[0]);
15+
assert(u.x3[1]);
16+
assert(u.x3[2]);
17+
18+
assert(*((char *)&u.x1));
19+
assert(*(((char *)&u.x1) + 1));
20+
assert(*(((char *)&u.x1) + 2));
21+
char s = *(((char *)&u.x1) + 3);
22+
assert(s);
23+
return 0;
24+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
KNOWNBUG
2+
main.c
3+
--verbosity 10
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
^warning: ignoring
9+
--
10+
assert(s) fails with field sensitivity, but passes without

0 commit comments

Comments
 (0)