Skip to content

Commit bff0c7e

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

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
@@ -1760,7 +1760,7 @@ optionalt<std::string> simplify_exprt::expr2bits(
17601760
if(
17611761
type.id() == ID_unsignedbv || type.id() == ID_signedbv ||
17621762
type.id() == ID_floatbv || type.id() == ID_fixedbv ||
1763-
type.id() == ID_c_bit_field || type.id() == ID_pointer)
1763+
type.id() == ID_c_bit_field)
17641764
{
17651765
const auto width = to_bitvector_type(type).get_width();
17661766

@@ -1773,6 +1773,13 @@ optionalt<std::string> simplify_exprt::expr2bits(
17731773

17741774
return result;
17751775
}
1776+
else if(type.id() == ID_pointer)
1777+
{
1778+
if(value == ID_NULL && config.ansi_c.NULL_is_zero)
1779+
return std::string('0', to_bitvector_type(type).get_width());
1780+
else
1781+
return {};
1782+
}
17761783
else if(type.id() == ID_c_enum_tag)
17771784
{
17781785
const auto &c_enum_type = ns.follow_tag(to_c_enum_tag_type(type));

0 commit comments

Comments
 (0)