From owner-freebsd-hackers@freebsd.org Fri Jan 15 18:45:29 2021 Return-Path: Delivered-To: freebsd-hackers@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 47CAB4EEE2C for ; Fri, 15 Jan 2021 18:45:29 +0000 (UTC) (envelope-from "") Received: from mout01.posteo.de (mout01.posteo.de [185.67.36.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4DHVVc3bRgz3NbV for ; Fri, 15 Jan 2021 18:45:28 +0000 (UTC) (envelope-from "") Received: from submission (posteo.de [89.146.220.130]) by mout01.posteo.de (Postfix) with ESMTPS id 096AC16005F for ; Fri, 15 Jan 2021 19:45:27 +0100 (CET) Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4DHVVY0hvWz9rxL for ; Fri, 15 Jan 2021 19:45:24 +0100 (CET) From: Walter von Entferndt To: freebsd-hackers@freebsd.org Subject: Re: Implicit assumptions (was: Re: Some fun with -O2) Date: Fri, 15 Jan 2021 19:43:14 +0100 Message-ID: <179047366.Z9jOzuS0a2@t450s.local.lan> In-Reply-To: <8D35ADAE-8904-4400-9DEB-7B274189BC30@yahoo.com> References: <4842729.YNO7O01DYZ@t450s.local.lan> <8D35ADAE-8904-4400-9DEB-7B274189BC30@yahoo.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="nextPart12097100.5MqMfjp4zD" Content-Transfer-Encoding: 7Bit X-Rspamd-Queue-Id: 4DHVVc3bRgz3NbV X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=fail reason="No valid SPF, No valid DKIM" header.from=posteo.net (policy=none); spf=none (mx1.freebsd.org: domain of mout01.posteo.de has no SPF policy when checking 185.67.36.141) smtp.helo=mout01.posteo.de X-Spamd-Result: default: False [-2.70 / 15.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; CTE_CASE(0.50)[]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; MIME_GOOD(-0.10)[multipart/mixed,text/plain,text/x-patch]; PREVIOUSLY_DELIVERED(0.00)[freebsd-hackers@freebsd.org]; TO_DN_NONE(0.00)[]; HAS_ATTACHMENT(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; RCVD_COUNT_THREE(0.00)[3]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; RCVD_IN_DNSWL_MED(-0.20)[185.67.36.141:from]; NEURAL_HAM_SHORT(-1.00)[-1.000]; R_SPF_NA(0.00)[no SPF record]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+,1:+,2:+]; ASN(0.00)[asn:8495, ipnet:185.67.36.0/23, country:DE]; RCVD_TLS_ALL(0.00)[]; MAILMAN_DEST(0.00)[freebsd-hackers]; DMARC_POLICY_SOFTFAIL(0.10)[posteo.net : No valid SPF, No valid DKIM,none] X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Jan 2021 18:45:29 -0000 This is a multi-part message in MIME format. --nextPart12097100.5MqMfjp4zD Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Dear Sirs, the behaviour on signed overflow is /explicitely undefined/ in C... I'd like to kindly suggest to fix the bug instead of fiddling around with compiler switches to compile a buggy program: --- check_mktime.c.patch --- --- check_mktime.c.orig 2021-01-15 03:19:33.962253000 +0100 +++ check_mktime.c 2021-01-15 04:04:22.291014000 +0100 @@ -1,13 +1,16 @@ /* Test program from Paul Eggert (eggert@twinsun.com) and Tony Leneis (tony@plaza.ds.adp.com). */ # include +# include /* NBBY: #bits of a byte */ # include # include +# include /* Work around redefinition to rpl_putenv by other config tests. */ #undef putenv -static time_t time_t_max; +const time_t t0 = (time_t) 1 << (NBBY*sizeof t0 - 2); /* unused elsewhere */ +static const time_t time_t_max = t0|(t0 - 1); /* Values we'll use to set the TZ environment variable. */ static const char *const tz_strings[] = { @@ -106,9 +109,6 @@ time_t t, delta; int i, j; - for (time_t_max = 1; 0 < time_t_max; time_t_max *= 2) - continue; - time_t_max--; delta = time_t_max / 997; /* a suitable prime number */ for (i = 0; i < N_STRINGS; i++) { -- =|o) "Stell' Dir vor es geht und keiner kriegt's hin." (Wolfgang Neuss) --nextPart12097100.5MqMfjp4zD Content-Disposition: attachment; filename="check_mktime.c.patch" Content-Transfer-Encoding: 7Bit Content-Type: text/x-patch; charset="UTF-8"; name="check_mktime.c.patch" --- check_mktime.c.orig 2021-01-15 03:19:33.962253000 +0100 +++ check_mktime.c 2021-01-15 04:04:22.291014000 +0100 @@ -1,13 +1,16 @@ /* Test program from Paul Eggert (eggert@twinsun.com) and Tony Leneis (tony@plaza.ds.adp.com). */ # include +# include /* NBBY: #bits of a byte */ # include # include +# include /* Work around redefinition to rpl_putenv by other config tests. */ #undef putenv -static time_t time_t_max; +const time_t t0 = (time_t) 1 << (NBBY*sizeof t0 - 2); /* unused elsewhere */ +static const time_t time_t_max = t0|(t0 - 1); /* Values we'll use to set the TZ environment variable. */ static const char *const tz_strings[] = { @@ -106,9 +109,6 @@ time_t t, delta; int i, j; - for (time_t_max = 1; 0 < time_t_max; time_t_max *= 2) - continue; - time_t_max--; delta = time_t_max / 997; /* a suitable prime number */ for (i = 0; i < N_STRINGS; i++) { --nextPart12097100.5MqMfjp4zD--