Skip to content

Use bv_typet to fix type consistency in byte-operator lowering #4519

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 3 commits into from
Apr 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions regression/cbmc/Bitfields3/paths.desc
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ main.c
^VERIFICATION SUCCESSFUL$
--
^warning: ignoring
--
This test is marked broken-smt-backend for performance reasons only: it passes,
but takes 5 seconds to do so.
2 changes: 1 addition & 1 deletion regression/cbmc/Bitfields3/test.desc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CORE broken-smt-backend
CORE
main.c
--pointer-check --bounds-check
^EXIT=0$
Expand Down
2 changes: 1 addition & 1 deletion regression/cbmc/Malloc23/test.desc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CORE broken-smt-backend
CORE
main.c
--pointer-check
^EXIT=10$
Expand Down
2 changes: 1 addition & 1 deletion regression/cbmc/Pointer_Arithmetic11/test.desc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CORE broken-smt-backend
CORE
main.c
--pointer-check --little-endian
^EXIT=0$
Expand Down
2 changes: 1 addition & 1 deletion regression/cbmc/Pointer_byte_extract2/test.desc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CORE broken-smt-backend
CORE
main.c
--little-endian
^EXIT=10$
Expand Down
2 changes: 1 addition & 1 deletion regression/cbmc/Pointer_byte_extract9/test.desc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CORE broken-smt-backend
CORE
main.c

^EXIT=10$
Expand Down
2 changes: 1 addition & 1 deletion regression/cbmc/Quantifiers-assignment/test.desc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CORE broken-smt-backend
CORE
main.c

^\*\* Results:$
Expand Down
2 changes: 1 addition & 1 deletion regression/cbmc/byte_update3/test.desc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CORE broken-smt-backend
CORE
main.c
--little-endian
^EXIT=0$
Expand Down
2 changes: 1 addition & 1 deletion regression/cbmc/byte_update5/test.desc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CORE broken-smt-backend
CORE
main.c
--little-endian
^EXIT=0$
Expand Down
2 changes: 1 addition & 1 deletion regression/cbmc/memory_allocation2/test.desc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CORE broken-smt-backend
CORE
main.c
--bounds-check
^EXIT=10$
Expand Down
37 changes: 22 additions & 15 deletions src/solvers/flattening/boolbv_typecast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ bool boolbvt::type_conversion(
{
INVARIANT(
src_width == dest_width,
"source bitvector with shall equal the destination bitvector width");
"source bitvector width shall equal the destination bitvector width");
dest=src;
return false;
}
Expand Down Expand Up @@ -415,24 +415,31 @@ bool boolbvt::type_conversion(
}
break;

default:
if(src_type.id()==ID_bool)
{
// bool to integer

case bvtypet::IS_BV:
INVARIANT(
src_width == 1, "bitvector of type boolean shall have width one");
src_width == dest_width,
"source bitvector width shall equal the destination bitvector width");
dest = src;
return false;

for(std::size_t i=0; i<dest_width; i++)
default:
if(src_type.id() == ID_bool)
{
if(i==0)
dest.push_back(src[0]);
else
dest.push_back(const_literal(false));
}
// bool to integer

return false;
}
INVARIANT(
src_width == 1, "bitvector of type boolean shall have width one");

for(std::size_t i = 0; i < dest_width; i++)
{
if(i == 0)
dest.push_back(src[0]);
else
dest.push_back(const_literal(false));
}

return false;
}
}
break;

Expand Down
Loading