Jenkins build is still unstable: FreeBSD_HEAD-tests2 #867

Garrett Cooper yaneurabeya at gmail.com
Sun Mar 22 21:37:31 UTC 2015


On Mar 22, 2015, at 14:36, Dimitry Andric <dim at FreeBSD.org> wrote:

> On 22 Mar 2015, at 22:32, Craig Rodrigues <rodrigc at FreeBSD.org> wrote:
>> 
>> On Sun, Mar 22, 2015 at 2:29 PM, Dimitry Andric <dim at freebsd.org> wrote:
>> 
>> Ah right, that was on i386, on amd64 it does result in -2^63.  It is indeed caused by reliance on signed integer wrapping.
>> 
>> This diff should fix it, without rewriting the utility:
>> 
>> Index: bin/expr/Makefile
>> ===================================================================
>> --- bin/expr/Makefile   (revision 280156)
>> +++ bin/expr/Makefile   (working copy)
>> @@ -6,6 +6,9 @@ PROG=   expr
>> SRCS=  expr.y
>> YFLAGS=
>> 
>> +# expr relies on signed integer wrapping
>> +CFLAGS+= -fwrapv
>> +
>> NO_WMISSING_VARIABLE_DECLARATIONS=
>> 
>> .if ${MK_TESTS} != "no"
>> 
>> 
>> Well, another alternative is to patch expr.y:
>> 
>> Index: expr.y
>> ===================================================================
>> --- expr.y      (revision 280353)
>> +++ expr.y      (working copy)
>> @@ -393,7 +393,7 @@
>> }
>> 
>> void
>> -assert_plus(intmax_t a, intmax_t b, intmax_t r)
>> +assert_plus(intmax_t a, intmax_t b, volatile intmax_t r)
>> {
>>        /*
>>         * sum of two positive numbers must be positive,
>> @@ -420,7 +420,7 @@
>> }
>> 
>> void
>> -assert_minus(intmax_t a, intmax_t b, intmax_t r)
>> +assert_minus(intmax_t a, intmax_t b, volatile intmax_t r)
>> {
>>        /* special case subtraction of INTMAX_MIN */
>>        if (b == INTMAX_MIN && a < 0)
>> 
>> 
>> There were already some patches previously done to this
>> file to add "volatile", so maybe this would be OK to do.
>> 
>> What do you think?
> 
> Volatile is not the solution, it is completely orthogonal.  The correct
> way would be to use unsigned integers, for which wrapping is defined,
> then convert those back and forth when presenting the results to the
> user.

Before doing that — what changed in the past week that changed the behavior of expr?
Thanks!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 496 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://lists.freebsd.org/pipermail/freebsd-current/attachments/20150322/abddf896/attachment.sig>


More information about the freebsd-current mailing list