Skip to content

Commit

Permalink
Explicitly truncate/widen shift value in OptimizeVisitor::PowExp
Browse files Browse the repository at this point in the history
  • Loading branch information
ibuclaw committed Dec 13, 2014
1 parent 048a508 commit 922fe5b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/optimize.c
Expand Up @@ -932,7 +932,8 @@ Expression *Expression_optimize(Expression *e, int result, bool keepLvalue)
while ((i >>= 1) > 1)
mul++;
Expression *shift = new MulExp(e->loc, e->e2, new IntegerExp(e->loc, mul, e->e2->type));
shift->type = Type::tshiftcnt;
shift->type = e->e2->type;
shift = shift->castTo(NULL, Type::tshiftcnt);
ret = new ShlExp(e->loc, new IntegerExp(e->loc, 1, e->e1->type), shift);
ret->type = e->type;
return;
Expand Down

0 comments on commit 922fe5b

Please sign in to comment.