Jenkins build is still unstable: FreeBSD_HEAD-tests2 #867

David Chisnall theraven at FreeBSD.org
Mon Mar 23 09:39:30 UTC 2015


On 22 Mar 2015, at 22:01, Craig Rodrigues <rodrigc at FreeBSD.org> wrote:
> 
>> 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.
>> 
> 
> OK, converting expr.y to use unsigned integers would require a bit of work.

Note that clang has, for a few releases, had builtins that allow overflow-checked operations and will generate very efficient code.  In op_times, I believe the following should work:

	long long mul;
#if __has_builtin(__builtin_smulll_overflow)
	if (__builtin_smulll_overflow(a->u.i, b->u.i, &mul))
		errx(ERR_EXIT, "overflow"); 
#else
	mul = a->u.i * b->u.i;
#endif
	r = make_integer(mul);

I don't know if recent versions of gcc implement these builtins yet.  I think they were added to clang around 3.4, possibly slightly earlier.  

David



More information about the freebsd-current mailing list