Skip to content

Commit a74e822

Browse files
committed
fix the constructor of element_address_exprt
The constructor now asserts that the base expression is a pointer, not an array.
1 parent de9e29e commit a74e822

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/util/pointer_expr.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,13 +147,13 @@ field_address_exprt::field_address_exprt(
147147
set(ID_component_name, component_name);
148148
}
149149

150-
element_address_exprt::element_address_exprt(exprt base, exprt index)
150+
element_address_exprt::element_address_exprt(const exprt &base, exprt index)
151151
: binary_exprt(
152-
std::move(base),
152+
base, // used for type, can't move
153153
ID_element_address,
154154
std::move(index),
155155
pointer_typet(
156-
to_array_type(base.type()).element_type(),
156+
to_pointer_type(base.type()).base_type(),
157157
to_pointer_type(base.type()).get_width()))
158158
{
159159
}

src/util/pointer_expr.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ class element_address_exprt : public binary_exprt
569569
/// constructor for element addresses.
570570
/// The base address must be a pointer to an element.
571571
/// The index is expected to have an integer type.
572-
element_address_exprt(exprt base, exprt index);
572+
element_address_exprt(const exprt &base, exprt index);
573573

574574
const pointer_typet &type() const
575575
{

0 commit comments

Comments
 (0)