Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 14 Jan 2021 13:04:54 +0100
From:      Dimitry Andric <dim@FreeBSD.org>
To:        Thierry Thomas <thierry@FreeBSD.org>
Cc:        FreeBSD Hackerz <hackers@freebsd.org>
Subject:   Re: Some fun with -O2
Message-ID:  <5E0B4EA1-0F24-41C2-AEDD-F9D127B5D290@FreeBSD.org>
In-Reply-To: <YAAqI08bgBtfpssP@graf.pompo.net>
References:  <YAAqI08bgBtfpssP@graf.pompo.net>

next in thread | previous in thread | raw e-mail | index | archive | help

--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 <thierry@FreeBSD.org> wrote:
>=20
> Let=C2=B4s check a small C program, check_mktime.c, fetchable from
> <https://people.freebsd.org/~thierry/check_mktime.c>.
>=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--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?5E0B4EA1-0F24-41C2-AEDD-F9D127B5D290>