Skip to content

Commit 9c5b9b3

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 0a09814 commit 9c5b9b3

File tree

6 files changed

+74
-0
lines changed

6 files changed

+74
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#include <assert.h>
2+
3+
struct s {
4+
union U {
5+
char c;
6+
char b[2];
7+
} u;
8+
} X;
9+
10+
int main() {
11+
// expected to fail
12+
__CPROVER_assert(X.u.b[1] == 2, "should fail");
13+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
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.

regression/cbmc/union/union_member.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#include <assert.h>
2+
3+
struct s {
4+
union U {
5+
char b[2];
6+
};
7+
};
8+
9+
int main() {
10+
struct s X;
11+
__CPROVER_assert(X.b[1] == 2, "should fail");
12+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
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.

regression/cbmc/union/union_update.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#include <assert.h>
2+
3+
struct s {
4+
char a;
5+
union U {
6+
char c;
7+
char b[2];
8+
} u;
9+
} X = { 1, 2 };
10+
11+
int main() {
12+
__CPROVER_assert(X.u.b[1] == 123, "should fail");
13+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
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.

0 commit comments

Comments
 (0)