The current implementation of operations - + * / % could cause Undefined
Behavior and in narrow cases (INT64_MIN / -1 and INT64_MIN % -1) SIGFPE
and crash duping core.
Detected with MKSANITIZER enabled for the Undefined Behavior variation:
# eval expr '4611686018427387904 + 4611686018427387904'
/public/src.git/bin/expr/expr.y:315:12: runtime error: signed integer overflow: 4611686018427387904 + 4611686018427387904 cannot be represented in type 'long'
All bin/t_expr ATF tests pass now in a sanitized userland.
Sponsored by <The NetBSD Foundation>
- HAVE_GCC=5 is now the default (vs. HAVE_GCC=53 we've been using for
GCC 5.4 and GCC 5.5.)
- remove some more GCC 4.8 code. we don't support GCC 4 here.
- adjust set lists to gcc=5 from gcc=53.
add some basic HAVE_GCC=6 handling (totally unused so far.)
Move email addresses to same line as author name.
Do not split the third author entry on to a new line.
Public domain is not licensed by definition, heads up by Robert Elz.
Change the add/subtract overflow checks to use an unsigned to do the op
and then cast back into the signed var to check the signs.
Make multiply shortcut on either right or left being 0.
Make multiply's overflow test not fail on simple cases like 1 * -1
Make the multiple overflow test pass all the regress tests.
Make sure all precendence is spelled out correctly (comparison does not
have the same level as the arithmetic operators..)
Break the arithemtic operators into 2 classes (+- are lower than */%)
Restructure the arithmetic code into a function either class above can call.
Finally, add a whole suite of regression tests (checked in separately) which
the previous code failed on 3 of them.
it's ignored if it would cause syntax error, otherwise treated as common
string; this is so that both 'expr -- : .' and 'expr -- foo : .' works
This addresses standards/11230 by Ben Harris.
while here, make all global variables but main() static, use const more