Skip to content

Commit b866475

Browse files
committed
Handle bool expressions in implicit_typecast_arithmetic
We use Booleans instead of int as type of binary predicates. This must not preclude mixing binary predicates with bitvector-typed expressions. Fixes: diffblue#5103
1 parent 6908502 commit b866475

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
int main(int argc, char *argv[])
2+
{
3+
unsigned __int128 z;
4+
z = (unsigned __int128)argc;
5+
z += (argc < 1);
6+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CORE gcc-only
2+
main.c
3+
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
--
7+
^CONVERSION ERROR$

src/ansi-c/c_typecast.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -627,8 +627,10 @@ void c_typecastt::implicit_typecast_arithmetic(
627627
if(max_type==LARGE_SIGNED_INT || max_type==LARGE_UNSIGNED_INT)
628628
{
629629
// get the biggest width of both
630-
std::size_t width1 = to_bitvector_type(type1).get_width();
631-
std::size_t width2 = to_bitvector_type(type2).get_width();
630+
std::size_t width1 =
631+
type1.id() == ID_bool ? 1 : to_bitvector_type(type1).get_width();
632+
std::size_t width2 =
633+
type2.id() == ID_bool ? 1 : to_bitvector_type(type2).get_width();
632634

633635
// produce type
634636
typet result_type;

0 commit comments

Comments
 (0)