From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/10788 Path: news.gmane.org!.POSTED!not-for-mail From: Szabolcs Nagy Newsgroups: gmane.linux.lib.musl.general Subject: Re: jrand48(): missing cast to int32_t? Date: Fri, 9 Dec 2016 18:05:13 +0100 Message-ID: <20161209170512.GD16379@port70.net> References: Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: blaine.gmane.org 1481303132 28971 195.159.176.226 (9 Dec 2016 17:05:32 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 9 Dec 2016 17:05:32 +0000 (UTC) User-Agent: Mutt/1.6.0 (2016-04-01) Cc: musl@lists.openwall.com To: Ed Schouten Original-X-From: musl-return-10801-gllmg-musl=m.gmane.org@lists.openwall.com Fri Dec 09 18:05:27 2016 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.84_2) (envelope-from ) id 1cFObt-0006Bp-8t for gllmg-musl@m.gmane.org; Fri, 09 Dec 2016 18:05:25 +0100 Original-Received: (qmail 21688 invoked by uid 550); 9 Dec 2016 17:05:25 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 21670 invoked from network); 9 Dec 2016 17:05:24 -0000 Mail-Followup-To: Ed Schouten , musl@lists.openwall.com Content-Disposition: inline In-Reply-To: Xref: news.gmane.org gmane.linux.lib.musl.general:10788 Archived-At: * Ed Schouten [2016-12-09 07:16:42 +0100]: > According to POSIX, jrand48() is supposed to return a value between > [-2^31, 2^31). Musl's version of jrand48() is implemented as follows: > > long jrand48(unsigned short s[3]) > { > return __rand48_step(s, __seed48+3) >> 16; > } nice catch, note that posix does not guarantee that long can represent -2^31 so this requirement is not possible to implement portably (indeed your proposed cast has implementation defined effect, but in musl we already rely on it to work as expected). i submitted a posix bug report against limits.h http://austingroupbugs.net/view.php?id=1108