Skip to content

add three tests for unions in structs #7278

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions regression/cbmc/union/union_initialization.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include <assert.h>

struct s
{
union U
{
char c;
char b[2];
} u;
} X;

int main()
{
// expected to fail
__CPROVER_assert(X.u.b[1] == 2, "should fail");
}
13 changes: 13 additions & 0 deletions regression/cbmc/union/union_initialization.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
CORE broken-smt-backend
union_initialization.c

^EXIT=10$
^SIGNAL=0$
^\[main\.assertion\.1\] line \d+ should fail: FAILURE$
^\*\* 1 of 1 failed
^VERIFICATION FAILED$
--
^warning: ignoring
--
This fails when using the SMT backend with Z3 with the error message
"invalid function/constant definition, sort mismatch".
15 changes: 15 additions & 0 deletions regression/cbmc/union/union_member.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include <assert.h>

struct s
{
union U
{
char b[2];
};
};

int main()
{
struct s X;
__CPROVER_assert(X.b[1] == 2, "should fail");
}
13 changes: 13 additions & 0 deletions regression/cbmc/union/union_member.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
CORE broken-smt-backend
union_member.c

^EXIT=10$
^SIGNAL=0$
^\[main\.assertion\.1\] line \d+ should fail: FAILURE$
^\*\* 1 of 1 failed
^VERIFICATION FAILED$
--
^warning: ignoring
--
This fails when using the SMT backend with Z3 with the error message
"select requires 1 arguments, but was provided with 2 arguments"
16 changes: 16 additions & 0 deletions regression/cbmc/union/union_update.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include <assert.h>

struct s
{
char a;
union U
{
char c;
char b[2];
} u;
} X = {1, 2};

int main()
{
__CPROVER_assert(X.u.b[1] == 123, "should fail");
}
13 changes: 13 additions & 0 deletions regression/cbmc/union/union_update.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
CORE broken-smt-backend
union_update.c

^EXIT=10$
^SIGNAL=0$
^\[main\.assertion\.1\] line \d+ should fail: FAILURE$
^\*\* 1 of 1 failed
^VERIFICATION FAILED$
--
^warning: ignoring
--
This fails when using the SMT backend with Z3 with the error message
"store expects the first argument sort to be an array".