From owner-svn-src-head@FreeBSD.ORG Fri Feb 27 15:12:10 2015 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id EB61FB6D; Fri, 27 Feb 2015 15:12:10 +0000 (UTC) Received: from mail-we0-x22f.google.com (mail-we0-x22f.google.com [IPv6:2a00:1450:400c:c03::22f]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 79D6B940; Fri, 27 Feb 2015 15:12:10 +0000 (UTC) Received: by wesq59 with SMTP id q59so21032890wes.1; Fri, 27 Feb 2015 07:12:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=gpxXvN/agmxLc7gjHw4mCi9Qv4yv0zwGeLZBIO+hHFc=; b=WsRZvV6QtCcDcD3f6RPLoVVD2Q/kS51xbweqPEh8hXDghY1jFoxFuKMkHB4P1iQKF1 /1+eUEzlMutT307zJeVjgrHm5IB8wKfiS7GPfMGImE8Tgqwc5D4odk7mtIWPWB0AsyGL j8ZVGet+tk9WBn7RzT8+VGgzqnEPvYOnDC36hSPMiv2hAK/RUHxvq2YYnrHiq7coKWRY FiEwo65SqKxsYCxrkcVBPvjO1uUxKZSiXXbKDNSwZCES+QMRh79VAGTCJc1bI26RZGzy 0EF6DM8xaDPnPz3yrcCLk8l3zkTN4MaXvoD2PDnyqPPfuMuUCXWbtcO1JX4/XJicz/TJ 9OvQ== MIME-Version: 1.0 X-Received: by 10.181.29.168 with SMTP id jx8mr7505741wid.8.1425049928933; Fri, 27 Feb 2015 07:12:08 -0800 (PST) Received: by 10.27.77.199 with HTTP; Fri, 27 Feb 2015 07:12:08 -0800 (PST) In-Reply-To: <20150227202646.I2088@besplex.bde.org> References: <201502270256.t1R2uxnv085328@svn.freebsd.org> <20150227082257.3fb1081c@bender.Home> <20150227202646.I2088@besplex.bde.org> Date: Fri, 27 Feb 2015 10:12:08 -0500 Message-ID: Subject: Re: svn commit: r279349 - head/sys/kern From: Benjamin Kaduk To: Bruce Evans Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.18-1 Cc: "svn-src-head@freebsd.org" , "svn-src-all@freebsd.org" , "src-committers@freebsd.org" , Warner Losh , Andrew Turner X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Feb 2015 15:12:11 -0000 On Fri, Feb 27, 2015 at 4:56 AM, Bruce Evans wrote: > On Fri, 27 Feb 2015, Andrew Turner wrote: > > On Fri, 27 Feb 2015 02:56:59 +0000 (UTC) >> Warner Losh wrote: >> ... >> >>> >>> Didn't we recently have issues with signed integer overflow being >> undefined? Even though we worked around it with a compiler flag it >> would be better to not rely on undefined behaviour in the first place. >> > > The undefined behaviour is missing in old rand() in libc. That uses > unsigned long internally to avoid the undefined behaviour and to not > depend on ints being 32 bits, but returns only 15 bits so that the > value can be represented as a (nonnegative) 16-bit int. Normally, > LCGs have a large multiplier that puts most randomness in the top > bits so lower bits should be discarded. This one does the opposite. > As of r278229, the kernel is compiled with -fwrapv, so signed integer overflow in the FreeBSD kernel is defined behavior. n1256.pdf's 3.4.1 example notes that right-shift of signed integer is implementation-defined, yes. -Ben