Support typecast from bv_typet to pointer_typet
The fixes in 848e633b67
result in type casts from bv_typet to various
other bitvector types being generated. Most cases were addressed in that
commit, but support for casting to pointers was omitted. This follow-up
commit fixes this, and adds a test specifically covering this case.
This commit is contained in:
parent
2a0cb4e314
commit
e7a4733116
|
@ -0,0 +1,15 @@
|
||||||
|
#include <assert.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
int **s = malloc(sizeof(int *));
|
||||||
|
for(int i = 0; i < sizeof(int *); ++i)
|
||||||
|
{
|
||||||
|
// A correct program would use (char *)s, but updating the pointer allows us
|
||||||
|
// to reproduce a bug in CBMC (missing support for typecasts from bv_typet
|
||||||
|
// to pointers).
|
||||||
|
*((char *)&s + i) = 0;
|
||||||
|
}
|
||||||
|
assert(s[0] == 0);
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
CORE
|
||||||
|
main.c
|
||||||
|
|
||||||
|
^EXIT=10$
|
||||||
|
^SIGNAL=0$
|
||||||
|
^VERIFICATION FAILED$
|
||||||
|
--
|
||||||
|
^warning: ignoring
|
||||||
|
--
|
||||||
|
This test makes sure we support bv_typet -> pointer type casts, avoiding
|
||||||
|
warnings like:
|
||||||
|
|
||||||
|
warning: ignoring typecast
|
||||||
|
* type: pointer
|
||||||
|
* width: 64
|
||||||
|
0: signedbv
|
||||||
|
* width: 32
|
||||||
|
* #c_type: signed_int
|
||||||
|
0: typecast
|
||||||
|
* type: bv
|
||||||
|
* width: 64
|
|
@ -253,11 +253,10 @@ bvt bv_pointerst::convert_pointer_type(const exprt &expr)
|
||||||
|
|
||||||
if(op_type.id()==ID_pointer)
|
if(op_type.id()==ID_pointer)
|
||||||
return convert_bv(op);
|
return convert_bv(op);
|
||||||
else if(op_type.id()==ID_signedbv ||
|
else if(
|
||||||
op_type.id()==ID_unsignedbv ||
|
op_type.id() == ID_signedbv || op_type.id() == ID_unsignedbv ||
|
||||||
op_type.id()==ID_bool ||
|
op_type.id() == ID_bool || op_type.id() == ID_c_enum ||
|
||||||
op_type.id()==ID_c_enum ||
|
op_type.id() == ID_c_enum_tag || op_type.id() == ID_bv)
|
||||||
op_type.id()==ID_c_enum_tag)
|
|
||||||
{
|
{
|
||||||
// Cast from integer to pointer.
|
// Cast from integer to pointer.
|
||||||
// We just do a zero extension.
|
// We just do a zero extension.
|
||||||
|
|
Loading…
Reference in New Issue