-
Notifications
You must be signed in to change notification settings - Fork 273
Implement C library string functions via array_{copy,replace,set} #795
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
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
c33266a
Fix order of operands in extractbits_exprt
tautschnig 8033bee
Describe the internal endianness and bit organisation of internal bit…
tautschnig 808139b
Additional very basic regression tests for byte_update
tautschnig 2fd63f7
Avoid byte_extract on pointers reaching solvers/flattening
tautschnig 305e148
Added destination/source overlap checks to C string library
tautschnig 8deb3d9
Defer type resolution in array_{copy,set} until after dereferencing
tautschnig ad56a18
Added __CPROVER_array_replace to complement __CPROVER_array_set
tautschnig 8c7d1e3
Use array_{copy,replace,set} in C library to avoid loops
tautschnig af73aec
added memcpy_chk implementation
tautschnig 91aef54
Do not inline functions using arrays of symbolic size
tautschnig 237d8be
Fix and extend byte extract flattening
tautschnig a6daa8a
The offset of void* is the same as char*
tautschnig 353d5a9
Do not use ID_pointer_offset directly, use pointer_offset() from poin…
tautschnig a71a093
Dereferencing to void induces 0 read bytes
tautschnig ed0c88f
member_offset is strictly positive, use size_type instead of signed_s…
tautschnig File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,12 @@ | ||
#include <assert.h> | ||
|
||
int main() | ||
{ | ||
int x=0x01020304; | ||
short *p=((short*)&x)+1; | ||
*p=0xABCD; | ||
assert(x==0xABCD0304); | ||
p=(short*)(((char*)&x)+1); | ||
*p=0xABCD; | ||
assert(x==0xABABCD04); | ||
} |
This file contains hidden or 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 | ||
|
||
^EXIT=0$ | ||
^SIGNAL=0$ | ||
^VERIFICATION SUCCESSFUL$ | ||
-- | ||
^warning: ignoring |
This file contains hidden or 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,12 @@ | ||
#include <assert.h> | ||
|
||
int main() | ||
{ | ||
int x=0x01020304; | ||
short *p=((short*)&x)+1; | ||
*p=0xABCD; | ||
assert(x==0x0102ABCD); | ||
p=(short*)(((char*)&x)+1); | ||
*p=0xABCD; | ||
assert(x==0x01ABCDCD); | ||
} |
This file contains hidden or 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 | ||
--big-endian | ||
^EXIT=0$ | ||
^SIGNAL=0$ | ||
^VERIFICATION SUCCESSFUL$ | ||
-- | ||
^warning: ignoring |
This file contains hidden or 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,30 @@ | ||
#include <stdlib.h> | ||
|
||
int *array; | ||
|
||
int main() | ||
{ | ||
unsigned size; | ||
__CPROVER_assume(size==1); | ||
|
||
// produce unbounded array that does not have byte granularity | ||
array=malloc(size*sizeof(int)); | ||
array[0]=0x01020304; | ||
|
||
int array0=array[0]; | ||
__CPROVER_assert(array0==0x01020304, "array[0] matches"); | ||
|
||
char *p=(char *)array; | ||
char p0=p[0]; | ||
char p1=p[1]; | ||
char p2=p[2]; | ||
char p3=p[3]; | ||
__CPROVER_assert(p0==4, "p[0] matches"); | ||
__CPROVER_assert(p1==3, "p[1] matches"); | ||
__CPROVER_assert(p2==2, "p[2] matches"); | ||
__CPROVER_assert(p3==1, "p[3] matches"); | ||
|
||
unsigned short *q=(unsigned short *)array; | ||
unsigned short q0=q[0]; | ||
__CPROVER_assert(q0==0x0304, "p[0,1] matches"); | ||
} |
This file contains hidden or 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 | ||
--little-endian | ||
^EXIT=0$ | ||
^SIGNAL=0$ | ||
^VERIFICATION SUCCESSFUL$ | ||
-- | ||
^warning: ignoring |
This file contains hidden or 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,29 @@ | ||
#include <string.h> | ||
#include <stdlib.h> | ||
#include <assert.h> | ||
|
||
int main() | ||
{ | ||
int A[5]; | ||
memset(A, 0, sizeof(int)*5); | ||
assert(A[0]==0); | ||
assert(A[1]==0); | ||
assert(A[2]==0); | ||
assert(A[3]==0); | ||
assert(A[4]==0); | ||
|
||
A[3]=42; | ||
memset(A, 0xFFFFFF01, sizeof(int)*3); | ||
assert(A[0]==0x01010101); | ||
assert(A[1]==0x01010111); | ||
assert(A[2]==0x01010101); | ||
assert(A[3]==42); | ||
assert(A[4]==0); | ||
|
||
int *B=malloc(sizeof(int)*2); | ||
memset(B, 2, sizeof(int)*2); | ||
assert(B[0]==0x02020202); | ||
assert(B[1]==0x02020202); | ||
|
||
return 0; | ||
} |
This file contains hidden or 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,10 @@ | ||
CORE | ||
main.c | ||
|
||
^EXIT=10$ | ||
^SIGNAL=0$ | ||
^VERIFICATION FAILED$ | ||
\[main.assertion.7\] assertion A\[1\]==0x01010111: FAILURE | ||
\*\* 1 of 12 failed \(2 iterations\) | ||
-- | ||
^warning: ignoring |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason not to use array_set for the nmemb==1 case?