On Sun, 22 Mar 2015, Dimitry Andric wrote:
Log: Build expr with -fwrapv, since it relies on signed integer wrapping having defined behavior.
This was supposed to be fixed using a volatile hack, but I see that was only for multiplication. Wrapping is not undefined behaviour. You mean overflow. expr mainly relies on the undefined behaviour giving a result and not causing the tests that the result is correct being optimized away. All compilers on all normal systems give a result. The volatile hack prevents the excessive optimization. But expr uses sloppy tests for addition and subtraction. For multiplication and division, there is no simple correctness test and expr does a complete test. For addition and multiplication, it assumes that the overflow gives (2's complement) wrapping so that simple sign tests work.
Modified: head/bin/expr/Makefile ============================================================================== --- head/bin/expr/Makefile Sun Mar 22 22:00:29 2015 (r280356) +++ head/bin/expr/Makefile Sun Mar 22 22:40:32 2015 (r280357) @@ -6,6 +6,9 @@ PROG= expr SRCS= expr.y YFLAGS= +# expr relies on signed integer wrapping +CFLAGS+= -fwrapv
Hard-coded gcc flags make compiling with non-gcc compilers impossible. -fwrapv implies 2's complement, so might not be supported even by gcc. Bruce _______________________________________________ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"