From owner-freebsd-hackers@freebsd.org Thu Jan 14 12:17:51 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 4E80B4E0480 for ; Thu, 14 Jan 2021 12:17:51 +0000 (UTC) (envelope-from thierry@pompo.net) Received: from erza.lautre.net (erza.lautre.net [80.67.160.89]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "lautre.net", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DGjxp2PL9z3lgt for ; Thu, 14 Jan 2021 12:17:50 +0000 (UTC) (envelope-from thierry@pompo.net) Received: from graf.pompo.net (graf.pompo.net [78.225.128.39]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by erza.lautre.net (Postfix) with ESMTPSA id 5846FFA38F for ; Thu, 14 Jan 2021 13:17:48 +0100 (CET) Received: by graf.pompo.net (Postfix, from userid 1001) id 5B588A2CE35; Thu, 14 Jan 2021 13:17:47 +0100 (CET) Date: Thu, 14 Jan 2021 13:17:47 +0100 From: Thierry Thomas To: freebsd-hackers@freebsd.org Subject: Re: Some fun with -O2 Message-ID: Mail-Followup-To: freebsd-hackers@freebsd.org References: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Operating-System: FreeBSD 12.2-STABLE amd64 Organization: Kabbale Eros X-Face: (hRbQnK~Pt7$ct`!fupO(`y_WL4^-Iwn4@ly-.,[4xC4xc; y=\ipKMNm<1J>lv@PP~7Z<.t KjAnXLs: X-PGP: 0xF1C516B3C8359753 X-Rspamd-Queue-Id: 4DGjxp2PL9z3lgt X-Spamd-Bar: / Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=pass (mx1.freebsd.org: domain of thierry@pompo.net designates 80.67.160.89 as permitted sender) smtp.mailfrom=thierry@pompo.net X-Spamd-Result: default: False [-0.92 / 15.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; R_SPF_ALLOW(-0.20)[+mx]; TO_DN_NONE(0.00)[]; HAS_ORG_HEADER(0.00)[]; NEURAL_HAM_SHORT(-0.92)[-0.915]; FORGED_SENDER(0.30)[thierry@freebsd.org,thierry@pompo.net]; MIME_TRACE(0.00)[0:+]; RBL_DBL_DONT_QUERY_IPS(0.00)[80.67.160.89:from]; ASN(0.00)[asn:20766, ipnet:80.67.160.0/19, country:FR]; R_DKIM_NA(0.00)[]; FROM_NEQ_ENVFROM(0.00)[thierry@freebsd.org,thierry@pompo.net]; TO_DOM_EQ_FROM_DOM(0.00)[]; ARC_NA(0.00)[]; FREEFALL_USER(0.00)[thierry]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-hackers@freebsd.org]; DMARC_NA(0.00)[freebsd.org]; NEURAL_SPAM_MEDIUM(1.00)[1.000]; RCPT_COUNT_ONE(0.00)[1]; SPAMHAUS_ZRD(0.00)[80.67.160.89:from:127.0.2.255]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[]; MAILMAN_DEST(0.00)[freebsd-hackers] 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: Thu, 14 Jan 2021 12:17:51 -0000 Le jeu. 14 janv. 21 à 12:44:34 +0100, Konstantin Belousov écrivait : > There is no fun with this stuff. > > The time_t type is signed, then the loop > for (time_t_max = 1; 0 < time_t_max; time_t_max *= 2) > continue; > intent is to get signed overflow, which is UB. Modern compilers prefer to > shoot into your foot instead of following common sense. > > Workaround is to add -fwrapv compiler switch. Indeed, but the fun part is the different behaviour with / without -O2. -- Th. Thomas.