Skip to content

Commit e2ee2d6

Browse files
committed
add three tests for unions in structs
These tests pass with the built-in solver but fail with three different errors when using SMT.
1 parent 74b23a3 commit e2ee2d6

File tree

6 files changed

+86
-0
lines changed

6 files changed

+86
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#include <assert.h>
2+
3+
struct s
4+
{
5+
union U
6+
{
7+
char c;
8+
char b[2];
9+
} u;
10+
} X;
11+
12+
int main()
13+
{
14+
// expected to fail
15+
__CPROVER_assert(X.u.b[1] == 2, "should fail");
16+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
CORE broken-smt-backend
2+
union_initialization.c
3+
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
^\[main\.assertion\.1\] line \d+ should fail: FAILURE$
7+
^\*\* 1 of 1 failed
8+
^VERIFICATION FAILED$
9+
--
10+
^warning: ignoring
11+
--
12+
This fails when using the SMT backend with Z3 with the error message
13+
"invalid function/constant definition, sort mismatch".

regression/cbmc/union/union_member.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#include <assert.h>
2+
3+
struct s
4+
{
5+
union U
6+
{
7+
char b[2];
8+
};
9+
};
10+
11+
int main()
12+
{
13+
struct s X;
14+
__CPROVER_assert(X.b[1] == 2, "should fail");
15+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
CORE broken-smt-backend
2+
union_member.c
3+
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
^\[main\.assertion\.1\] line \d+ should fail: FAILURE$
7+
^\*\* 1 of 1 failed
8+
^VERIFICATION FAILED$
9+
--
10+
^warning: ignoring
11+
--
12+
This fails when using the SMT backend with Z3 with the error message
13+
"select requires 1 arguments, but was provided with 2 arguments"

regression/cbmc/union/union_update.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#include <assert.h>
2+
3+
struct s
4+
{
5+
char a;
6+
union U
7+
{
8+
char c;
9+
char b[2];
10+
} u;
11+
} X = {1, 2};
12+
13+
int main()
14+
{
15+
__CPROVER_assert(X.u.b[1] == 123, "should fail");
16+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
CORE broken-smt-backend
2+
union_update.c
3+
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
^\[main\.assertion\.1\] line \d+ should fail: FAILURE$
7+
^\*\* 1 of 1 failed
8+
^VERIFICATION FAILED$
9+
--
10+
^warning: ignoring
11+
--
12+
This fails when using the SMT backend with Z3 with the error message
13+
"store expects the first argument sort to be an array".

0 commit comments

Comments
 (0)