mirror of
https://github.com/zeek/zeek.git
synced 2025-10-06 16:48:19 +00:00
GH-219: fix |x| operator int overflow / floating point type inconsistency
When 'x' is an integral arithmetic expression, it's now coerced to yield a signed integer before taking the absolute value of it to prevent the common issue of unsigned integer overflow/wraparound for values below zero. Using a time or interval value/expression for 'x' now also yields a time or interval, respective, from the |x| operation instead of a double.
This commit is contained in:
parent
bebc0fba6d
commit
3256ac7c49
8 changed files with 21 additions and 6 deletions
|
@ -728,7 +728,12 @@ expr:
|
|||
| '|' expr '|' %prec '('
|
||||
{
|
||||
set_location(@1, @3);
|
||||
$$ = new SizeExpr($2);
|
||||
auto e = $2;
|
||||
|
||||
if ( IsIntegral(e->Type()->Tag()) )
|
||||
e = new ArithCoerceExpr(e, TYPE_INT);
|
||||
|
||||
$$ = new SizeExpr(e);
|
||||
}
|
||||
|
||||
| expr TOK_AS type
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue