From owner-freebsd-hackers@freebsd.org Thu Jan 14 12:05:05 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 4ED864DFF49 for ; Thu, 14 Jan 2021 12:05:05 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from mailman.nyi.freebsd.org (mailman.nyi.freebsd.org [IPv6:2610:1c1:1:606c::50:13]) by mx1.freebsd.org (Postfix) with ESMTP id 4DGjg51hQ9z3lC4 for ; Thu, 14 Jan 2021 12:05:05 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: by mailman.nyi.freebsd.org (Postfix) id 3830B4DFE78; Thu, 14 Jan 2021 12:05:05 +0000 (UTC) Delivered-To: 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 37F3E4DFF48 for ; Thu, 14 Jan 2021 12:05:05 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DGjg5143Yz3lH8; Thu, 14 Jan 2021 12:05:05 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from tensor.andric.com (tensor.andric.com [IPv6:2001:470:7a58:1::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "tensor.andric.com", Issuer "R3" (verified OK)) (Authenticated sender: dim) by smtp.freebsd.org (Postfix) with ESMTPSA id F2E0B1AE1; Thu, 14 Jan 2021 12:05:04 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from [IPv6:2001:470:7a58::5cfc:8384:2375:c6d] (unknown [IPv6:2001:470:7a58:0:5cfc:8384:2375:c6d]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by tensor.andric.com (Postfix) with ESMTPSA id 2A3A933F47; Thu, 14 Jan 2021 13:05:02 +0100 (CET) From: Dimitry Andric Message-Id: <5E0B4EA1-0F24-41C2-AEDD-F9D127B5D290@FreeBSD.org> Content-Type: multipart/signed; boundary="Apple-Mail=_33B68D4C-1DE7-44C6-B1EE-8E2F5E6AF82E"; protocol="application/pgp-signature"; micalg=pgp-sha1 Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.17\)) Subject: Re: Some fun with -O2 Date: Thu, 14 Jan 2021 13:04:54 +0100 In-Reply-To: Cc: FreeBSD Hackerz To: Thierry Thomas References: X-Mailer: Apple Mail (2.3445.104.17) 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:05:05 -0000 --Apple-Mail=_33B68D4C-1DE7-44C6-B1EE-8E2F5E6AF82E Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 On 14 Jan 2021, at 12:25, Thierry Thomas wrote: >=20 > Let=C2=B4s check a small C program, check_mktime.c, fetchable from > . >=20 > $CC -o check_mktime -O2 check_mktime.c > ./check_mktime $ gcc -fsanitize=3Dundefined check_mktime.c -o check_mktime <...lots of warnings snipped...> $ ./check_mktime check_mktime.c:109:51: runtime error: signed integer overflow: = 4611686018427387904 * 2 cannot be represented in type 'long int' check_mktime.c:111:13: runtime error: signed integer overflow: = -9223372036854775808 - 1 cannot be represented in type 'long int' check_mktime.c:123:28: runtime error: signed integer overflow: = 1073741824 * 2 cannot be represented in type 'int' check_mktime.c:125:7: runtime error: signed integer overflow: = -2147483648 - 1 cannot be represented in type 'int' This program indeed relies on -fwrapv. -Dimitry --Apple-Mail=_33B68D4C-1DE7-44C6-B1EE-8E2F5E6AF82E Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.2 iF0EARECAB0WIQR6tGLSzjX8bUI5T82wXqMKLiCWowUCYAAzZgAKCRCwXqMKLiCW o+p8AJ0RXoS2gDkHTWNSbxjyeye4WQa/8ACgmCobasaFEDND9qQodSFJkiYpg8M= =Jr7y -----END PGP SIGNATURE----- --Apple-Mail=_33B68D4C-1DE7-44C6-B1EE-8E2F5E6AF82E--