Skip to content

Commit 0c22c03

Browse files
author
Daniel Kroening
committed
expr2bits needs to handle pointer case
This fixes #4168. The pointer case was not handled.
1 parent a869788 commit 0c22c03

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

regression/cbmc/assigning_nullpointers_should_not_crash_symex/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include <assert.h>
2-
#include <stddef.h>
2+
#include <stdlib.h>
33

44
struct linked_list
55
{

regression/cbmc/assigning_nullpointers_should_not_crash_symex/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
KNOWNBUG
1+
CORE broken-smt-backend
22
main.c
33

44
^EXIT=0$

src/util/simplify_expr.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1740,7 +1740,7 @@ optionalt<std::string> simplify_exprt::expr2bits(
17401740
if(
17411741
type.id() == ID_unsignedbv || type.id() == ID_signedbv ||
17421742
type.id() == ID_floatbv || type.id() == ID_fixedbv ||
1743-
type.id() == ID_c_bit_field || type.id() == ID_pointer)
1743+
type.id() == ID_c_bit_field)
17441744
{
17451745
const auto width = to_bitvector_type(type).get_width();
17461746

@@ -1753,6 +1753,13 @@ optionalt<std::string> simplify_exprt::expr2bits(
17531753

17541754
return result;
17551755
}
1756+
else if(type.id() == ID_pointer)
1757+
{
1758+
if(value == ID_NULL && config.ansi_c.NULL_is_zero)
1759+
return std::string('0', to_bitvector_type(type).get_width());
1760+
else
1761+
return {};
1762+
}
17561763
else if(type.id() == ID_c_enum_tag)
17571764
{
17581765
const auto &c_enum_type = ns.follow_tag(to_c_enum_tag_type(type));

0 commit comments

Comments
 (0)