Skip to content

Commit 478d0ee

Browse files
authored
Merge pull request #4059 from tautschnig/with-exprt-checks
with_exprt need only have an odd number of operands [blocks: #2068]
2 parents ebb52eb + 7e9ca51 commit 478d0ee

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/util/std_expr.h

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3445,8 +3445,8 @@ inline const with_exprt &to_with_expr(const exprt &expr)
34453445
{
34463446
PRECONDITION(expr.id()==ID_with);
34473447
DATA_INVARIANT(
3448-
expr.operands().size()==3,
3449-
"Array/structure update must have three operands");
3448+
expr.operands().size() >= 3 && expr.operands().size() % 2 == 1,
3449+
"array/structure update must have at least three operands");
34503450
return static_cast<const with_exprt &>(expr);
34513451
}
34523452

@@ -3455,8 +3455,8 @@ inline with_exprt &to_with_expr(exprt &expr)
34553455
{
34563456
PRECONDITION(expr.id()==ID_with);
34573457
DATA_INVARIANT(
3458-
expr.operands().size()==3,
3459-
"Array/structure update must have three operands");
3458+
expr.operands().size() >= 3 && expr.operands().size() % 2 == 1,
3459+
"array/structure update must have at least three operands");
34603460
return static_cast<with_exprt &>(expr);
34613461
}
34623462

@@ -3466,10 +3466,9 @@ template<> inline bool can_cast_expr<with_exprt>(const exprt &base)
34663466
}
34673467
inline void validate_expr(const with_exprt &value)
34683468
{
3469-
validate_operands(
3470-
value,
3471-
3,
3472-
"Array/structure update must have three operands");
3469+
DATA_INVARIANT(
3470+
value.operands().size() % 2 == 1,
3471+
"array/structure update must have an odd number of operands");
34733472
}
34743473

34753474
class index_designatort : public expr_protectedt

0 commit comments

Comments
 (0)