-
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.
Merge pull request #4717 from tautschnig/byte-operator-union
Byte-operator lowering: Add support for byte-extracting unions
- Loading branch information
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