-
Notifications
You must be signed in to change notification settings - Fork 271
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Value set dereferencing: do not treat struct prefixes as equal
Two distinct struct types cannot be cast between, even when one is a prefix of the other. Value set dereferencing taking this approach just resulted in propositional encoding producing a warning about invalid type casts.
- Loading branch information
1 parent
0a09814
commit 739b4d5
Showing
8 changed files
with
71 additions
and
55 deletions.
There are no files selected for viewing
11 changes: 0 additions & 11 deletions
11
jbmc/regression/jbmc/simplify-classid-of-interface/test_no_simplify_vccs.desc
This file was deleted.
Oops, something went wrong.
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,24 @@ | ||
struct T | ||
{ | ||
// intentionally empty to trigger is_prefix_of code (empty structs, however, | ||
// are a GCC-only feature) | ||
}; | ||
|
||
struct S | ||
{ | ||
struct T t; | ||
int other; | ||
}; | ||
|
||
void foo(struct S s2) | ||
{ | ||
struct T *p = &s2.t; | ||
struct T t2 = *p; | ||
__CPROVER_assert(0, ""); | ||
} | ||
|
||
int main() | ||
{ | ||
struct S s; | ||
foo(s); | ||
} |
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,11 @@ | ||
CORE gcc-only broken-smt-backend | ||
main.c | ||
|
||
^VERIFICATION FAILED$ | ||
^EXIT=10$ | ||
^SIGNAL=0$ | ||
-- | ||
^warning: ignoring | ||
-- | ||
This test must not generate a warning about typecasts (between different struct | ||
types) being ignored. |
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,28 @@ | ||
#include <assert.h> | ||
|
||
struct a | ||
{ | ||
int x; | ||
}; | ||
struct b | ||
{ | ||
struct a p; | ||
int y; | ||
}; | ||
|
||
int f00(struct a *ptr) | ||
{ | ||
return ptr->x; | ||
} | ||
|
||
int main() | ||
{ | ||
struct b z = {{1}, 2}; | ||
|
||
assert(&z == &(z.p)); | ||
assert(&z == &(z.p.x)); | ||
|
||
assert(f00(&z) == z.p.x); | ||
|
||
return 0; | ||
} |
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,8 @@ | ||
CORE | ||
main.c | ||
|
||
^VERIFICATION SUCCESSFUL$ | ||
^EXIT=0$ | ||
^SIGNAL=0$ | ||
-- | ||
^warning: ignoring |
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
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
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