Fix incorrect linearization of "x && y && z"
PATCH 1/1 Fix incorrect linearization of "x && y && z"
This fixes an incorrect assumption that results in && using shortcut logic on the true branch instead of the false branch.
Signed-off-by Daniel De Graaf <[email protected]>
--- linearize.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-)
linearize.c +4 -1
@@ -1389,7 +1389,10 @@ static pseudo_t linearize_logical(struct entrypoint *ep, struct expression *expr shortcut =alloc_const_expression (expr->pos, expr->op ==SPECIAL_LOGICAL_OR ); shortcut->ctype = expr->ctype; -return linearize_conditional (ep, expr, expr->left, shortcut, expr->right); +if (expr->op ==SPECIAL_LOGICAL_OR ) +return linearize_conditional (ep, expr, expr->left, shortcut, expr->right); +else +return linearize_conditional (ep, expr, expr->left, expr->right, shortcut); }static pseudo_t linearize_compare (struct entrypoint *ep,struct expression *expr)
Signature · 1 line
1.6.5
Christopher Li
maintainerQuoted 2 lines · Daniel De Graaf
This fixes an incorrect assumption that results in && using shortcut logic on the true branch instead of the false branch.
Good catch. Thanks!
I applied it without the "else" line.
Chris
PS. I almost miss this email because it is send to "unlisted-recipients". My patch tool catches it though.