From owner-freebsd-bugs@freebsd.org Sat Aug 12 10:59:34 2017 Return-Path: Delivered-To: freebsd-bugs@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1A163DCE260 for ; Sat, 12 Aug 2017 10:59:34 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail104.syd.optusnet.com.au (mail104.syd.optusnet.com.au [211.29.132.246]) by mx1.freebsd.org (Postfix) with ESMTP id D5D70817C9 for ; Sat, 12 Aug 2017 10:59:33 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from [192.168.0.102] (c110-21-101-228.carlnfd1.nsw.optusnet.com.au [110.21.101.228]) by mail104.syd.optusnet.com.au (Postfix) with ESMTPS id 9A16F4283C9 for ; Sat, 12 Aug 2017 20:59:24 +1000 (AEST) Date: Sat, 12 Aug 2017 20:59:23 +1000 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org cc: freebsd-bugs@freebsd.org Subject: Re: [Bug 221418] FreeBSD 10.4-PRERELEASE fails to build on systems using 32 bit time_t since r322315. In-Reply-To: Message-ID: <20170812204159.O1958@besplex.bde.org> References: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.2 cv=LI0WeNe9 c=1 sm=1 tr=0 a=PalzARQSbocsUSjMRkwAPg==:117 a=PalzARQSbocsUSjMRkwAPg==:17 a=9cW_t1CCXrUA:10 a=kj9zAlcOel0A:10 a=6I5d2MoRAAAA:8 a=vImwRviG-gIG5KMTo5EA:9 a=CjuIK1q_8ugA:10 a=IjZwj45LgO3ly-622nXo:22 X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 12 Aug 2017 10:59:34 -0000 On Fri, 11 Aug 2017 a bug that doesn't want replies@freebsd.org wrote: > --- Comment #1 from Conrad Meyer --- > Truncated INT64_MIN should be INT32_MIN on 2's complement, not 0. Seems like > we just lack a (time_t) cast on the value. Truncated INT64_MIN should be and is, 0 in 2's complement, since all of its low 32 bits are 0. In 1's complement, it should be -0, since all of its low 32 bits are 1. Casting to time_t is no different to assigning to time_t, except compilers usually only warn about overflow for the assignent. Casting thus enlarges the bug by breaking the warning about overflow. Related to this, the special value for possibly-invalid time_t's is ((time_t)-1), not some large negative value. This is large and positive if time_t is unsigned. In POSIX, times before the Epoch are invalid, but (time_t)-1) might be valid if it is positive. In Standard C, (time_t)-1) might be valid even if it is -1. I think the code needs a large negative value for technical reasons. INT64_MIN is very bogus for this, since 69 years in the past given by INT32_MIN should be enough for anyone, and further in the past than that is unrepresentable by time_t on systems with 32-bit signed time_t. If time_t is unsigned, no negative values are representable, so casts to int but not to time_t might be needed. > With regards to your patch, CHAR_BIT is always 8 on FreeBSD. CHAR_BIT is 8 on all POSIX systems later than 2001. CHAR_BIT is often spelled NBBY in BSD. NBBY is less verbose than CHAR_BIT and less cryptic than 8. Bruce