Fix bug dropping bounds checks for arrays. This addresses #943.

This commit is contained in:
Christoffer Lerno
2023-08-23 14:21:11 +02:00
parent 0120498ec8
commit 056ffa5876
2 changed files with 33 additions and 1 deletions

View File

@@ -676,7 +676,7 @@ static inline void gencontext_emit_subscript(GenContext *c, BEValue *value, Expr
{
// From back should always be folded.
assert(!expr_is_const(expr) || !expr->subscript_expr.range.start_from_end);
needs_len = (active_target.feature.safe_mode && expr_is_const(expr)) || expr->subscript_expr.range.start_from_end;
needs_len = (active_target.feature.safe_mode && !expr_is_const(expr)) || expr->subscript_expr.range.start_from_end;
}
if (needs_len)
{