-
Notifications
You must be signed in to change notification settings - Fork 265
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support byte-extract lowering over union of non-constant size
The test included made apparent that we weren't yet handling unbounded byte extracts (out of a bounded object) for unions, which just fell back to unpacking an empty array.
- Loading branch information
1 parent
b4a4122
commit 7032a1f
Showing
3 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
int main() | ||
{ | ||
// create a union type of non-constant, non-zero size | ||
unsigned x; | ||
__CPROVER_assume(x > 0); | ||
union U | ||
{ | ||
unsigned A[x]; | ||
}; | ||
// create an integer of arbitrary value | ||
int i, i_before; | ||
i_before = i; | ||
// initialize a union of non-zero size from the integer | ||
unsigned u = ((union U *)&i)->A[0]; | ||
// reading back an integer out of the union should yield the same value for | ||
// the integer as it had before | ||
i = u; | ||
__CPROVER_assert(i == i_before, "going through union works"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
CORE broken-smt-backend | ||
main.c | ||
--no-simplify | ||
^EXIT=0$ | ||
^SIGNAL=0$ | ||
^VERIFICATION SUCCESSFUL$ | ||
-- | ||
^warning: ignoring | ||
-- | ||
This test passes when simplification is enabled (which gets rid of | ||
byte-extracting a union of non-constant size), but yielded a wrong verification | ||
outcome with both the SAT back-end before. The SMT back-end fails for it would | ||
like to flatten an array of non-constant size. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters