-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
0 addresses are mapped to NULL, otherwise mapped to a pointer with an unconstrained provenance.
- Loading branch information
Showing
6 changed files
with
64 additions
and
6 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
void* cast(unsigned long long addr) | ||
/*@ | ||
ensures | ||
addr == 0u64 && is_null(return) || addr != 0u64 && has_alloc_id(return) && (u64) return == addr; | ||
@*/ | ||
{ | ||
return (void*)addr; | ||
} | ||
|
||
int main() | ||
{ | ||
int x = 0; | ||
void* p = cast((unsigned long long)&x); | ||
/*@ assert ((u64) &x == 0u64 || has_alloc_id(p) && (u64) p == (u64) &x); @*/ | ||
} |
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,17 @@ | ||
int* cast(unsigned long long addr) | ||
/*@ | ||
ensures | ||
addr == 0u64 && is_null(return) || addr != 0u64 && has_alloc_id(return) && (u64) return == addr; | ||
@*/ | ||
{ | ||
return (void*)addr; | ||
} | ||
|
||
int main() | ||
{ | ||
int x = 0; | ||
int* p = cast((unsigned long long)&x); | ||
// The cast is successful, but has an unconstrained allocation ID, and so | ||
// can't be used | ||
return *p == 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,15 @@ | ||
unsigned long long f(int *p) | ||
/*@ | ||
requires | ||
ptr_eq(p, NULL); | ||
ensures | ||
return == 0u64; | ||
@*/ | ||
{ | ||
return (unsigned long long)p; | ||
} | ||
|
||
int main() | ||
{ | ||
return f((int*)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