Skip to content

Commit 8d8c2e0

Browse files
Fix bug causing crash on Windows
A reference was being kept to a field of an element of a vector that had been swapped with another vector. Whether the original element still exists at the original memory location, preserving references, is implementation dependant and should not be relied upon.
1 parent 80060ea commit 8d8c2e0

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/ansi-c/c_typecheck_expr.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -1244,7 +1244,10 @@ void c_typecheck_baset::typecheck_expr_index(exprt &expr)
12441244

12451245
make_index_type(index_expr);
12461246

1247-
const typet &final_array_type=follow(array_expr.type());
1247+
// array_expr is a reference to one of expr.operands(), when that vector is
1248+
// swapped below the reference is no longer valid. final_array_type exists
1249+
// beyond that point so can't be a reference
1250+
const typet final_array_type = follow(array_expr.type());
12481251

12491252
if(final_array_type.id()==ID_array ||
12501253
final_array_type.id()==ID_vector)

0 commit comments

Comments
 (0)