From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from FRA01-PR2-obe.outbound.protection.outlook.com (mail-pr2fra01on2077.outbound.protection.outlook.com [40.107.12.77]) by sourceware.org (Postfix) with ESMTPS id EF5A13858C54 for ; Fri, 10 Mar 2023 07:34:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EF5A13858C54 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=trust-in-soft.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=trust-in-soft.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DZrHj9HV7R61p17berDZHd7qkzRl/b8lTvy4/3McZ4HhO3dDooktN6qSmeQ/MLoZfxBDDyEUrrNZ+9o++ulzaVAZWWEc8S6Wys9ss2KTQs8dMMVsTr17KDyTd/7Tm/3x0Kgr1t8ak2sbPY3MurDDPBZ3n3JDE1Ac+IIaMGwDVsYPhcr8Wwl9AQnT84SDRC4YS093oh0GVtBPFAXtFU4I42KtfY0DrpSeriwcLLTC0WpZ9MbISOzngYavrX9QZEpRBRyxgAUH65R5/lHYF+c8nsHaD25+s5WeUhWrsspqsz8GRMvWu0Z4sZkmCmurSJjLZWyMQd8VbMruy0jb9IktVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=4ZbtArbU5Q7yeEODd9Xd8UfApUCxfH/V6oZqVKhUJ94=; b=I5g2s1IOGqpBs/NwiDJ9gPw2JNqMXg2ZOUcQld5T/RAEJ5NPt64OhwEbl+8c3R9wK77At3HZQr8CMmHq5FMyWYtsdB1HS0erIvbi5JfJsCD+KrmSUb0/N0HkPKKwElaIH5x9IJEYR+orKPKelSwoYJthKthbJnFBQ3e6u7IN4+YfV2uj/Emo6oQ8M/veGHoh6upiyC01CkBZmO2geZg5LVB/u0+UksvntHGY4zMFQe2A8MW2ELzrPgyaLk5WkfhD0DOPWeRHqjt0SkeHpsy4cmFBA6Bf5Uomlvkme014WnMYWM4JQ0dLPoG+4P/M5//I1KTc8CAcBLb56eUiA6jFIQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=trust-in-soft.com; dmarc=pass action=none header.from=trust-in-soft.com; dkim=pass header.d=trust-in-soft.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=trust-in-soft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4ZbtArbU5Q7yeEODd9Xd8UfApUCxfH/V6oZqVKhUJ94=; b=GeoDZxsvXHTjCoXWqQtI2PETHofMG1lzTqWg+hYmXcdu1jCivhuiRvRBBR7T0P0/1sSe31UaiA0x+NBHrKj1BuAj5BVFYebh/7CpCPybwuQmlU79MLgD03mNG6ROKuKadP7IqkvJWVWISyduqkK4mNHyab2A7eeIGczR8ct3StHeY9QDo0rGvDb2J7Gy1sciYeaq9xBjhe8dREwzcl89+zND788OhrhcWl6RFnhbMaf5Db998Is4wj+dJQkDTvKNio2HrTaqIkUondDToFjUV5AGWBM8kV0IHZT12jGPBMygKRmZmBppKXXZKBhsH2OHxmr+dbxLCFhZenHVxsQCvA== Received: from PR0P264MB0794.FRAP264.PROD.OUTLOOK.COM (2603:10a6:100:8::20) by PR0P264MB1545.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:16d::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.19; Fri, 10 Mar 2023 07:34:30 +0000 Received: from PR0P264MB0794.FRAP264.PROD.OUTLOOK.COM ([fe80::3b3f:2f68:31b:2818]) by PR0P264MB0794.FRAP264.PROD.OUTLOOK.COM ([fe80::3b3f:2f68:31b:2818%4]) with mapi id 15.20.6178.019; Fri, 10 Mar 2023 07:34:30 +0000 From: Pascal Cuoq To: Alejandro Colomar , "mtk.manpages@gmail.com" CC: "linux-man@vger.kernel.org" , Guillaume Cluzel , GNU C Library , Andreas Schwab Subject: Re: nextafter underflow and errno in Glibc Thread-Topic: nextafter underflow and errno in Glibc Thread-Index: AQHZUyB6NMmIc9e8B0+V1dWqx+2sQQ== Date: Fri, 10 Mar 2023 07:34:30 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=trust-in-soft.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: PR0P264MB0794:EE_|PR0P264MB1545:EE_ x-ms-office365-filtering-correlation-id: 9f272f41-be39-4a4d-3da6-08db2139e28d x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: jkmmrLutiiDgDF7AsUimd/S9mMrvHZsZEdkRFAA6McaWqoLVwjq8BOBUr5LC1EASJAzT5jxUiiSSHdQc8au25MID4oZhb7hMah4Akfi5PIUDFjg2iqBKlRWbXEKrCvX+3fym8P2Owxr/Q4BhgHY8nIabJXRbzjssr30UgAvThKhaHmWqrc1qj3cxVrwXpj5jlkYetoLdz21PO8yfHHpUX3vtU5diJXcxLCuPBY3GXVcHHuPH0q0Ax86gPnftMGRTYUZU+jEPV0s1b/exsYwDA3cyLKSJVsrMpFExzXJxRai2jOfwPrjp+Z2/BOsCCE7vmYo+rO+igkJP0E0MnIzGSp4WkTWm/WqKhyZql6EoSi4R9aQZ7FzoIpQci2ZQMHCtGRx9d0eARC3uqp4nObfwIukNKCxJaCAfopbI4tdwXyDkursYm7VXN589RCa9XR1JSb4WpdrQ6hr31ZE/g+/8wL/KZqcePta00visk88/NKyGCXo5HzFFRi4Yygpdy4XWnI64ccm46e0YxCCWmBU4aRW6i3HoMKuI72TpOuoZeaHC2WeVX6uxzardBi8i9mfrzkzYqGRkaMXaxgR3pGZDdP0ci0aaT5BazqkMIRsH/X1tsCN8SZWKZa7qNuklyqlmb60w9LKuWetfJM9LvtU3aXZ6IFwhpe0aFyR95NUg0WB7eVdjMR3dMAn8jOJZXmC6 x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PR0P264MB0794.FRAP264.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230025)(4636009)(376002)(39840400004)(396003)(346002)(366004)(136003)(451199018)(33656002)(54906003)(316002)(110136005)(478600001)(966005)(52536014)(71200400001)(8936002)(5660300002)(7696005)(64756008)(21615005)(66446008)(76116006)(4326008)(91956017)(8676002)(66556008)(66946007)(66476007)(2906002)(166002)(6506007)(55016003)(38070700005)(86362001)(38100700002)(41300700001)(53546011)(186003)(9686003)(122000001)(26005)(83380400001)(19627405001)(66899018);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?Windows-1252?Q?8gluePNFnMeWqCNKWWTsnfrc9wik7VxBZ7iD98Kp5+4SPWRRLBlk7uGJ?= =?Windows-1252?Q?wYjBuwnoEV0hHw63CNKkkIqd5TlJzCUt9M1qH5aYu82xIhdFYYyM21WC?= =?Windows-1252?Q?ewXNcHwOAFQBUo+2IUOSjZdXIgb42VZX9IwdQ7WonMM0dEg9z8lb781D?= =?Windows-1252?Q?zOszbMt8LdCq69KT9tV2BHrmmYnPlkrmPUqIUUB2fDh4n3mNwxGoZhAR?= =?Windows-1252?Q?dkUdihRVVV9XKBa0cDhgE7L2aGLEYb3myunp9KhgMr7btmztwwDIDWR7?= =?Windows-1252?Q?GyfVbehzYnF24FqyP+bOL4aajppQuRHV878mx/eGrETCD79QAae5jgGq?= =?Windows-1252?Q?plxl3d1bunaabfqTyQ+DlBKSvDINFgYxvUn41U5K79MdFOKDkkajsxIM?= =?Windows-1252?Q?OuYQOP/lAVju4z3SNwNKBFBuwm3TD/r3wHPs9V/WoaNHjtexqaF+bESC?= =?Windows-1252?Q?GpvluJRxlDjnRAoOmQZbZX4/lU1xCVBfL3sOC/JD4Ob4UBsR6Sey5dRv?= =?Windows-1252?Q?Owr+0cAE8Nmx7O6xFJ2DsbClp1bRVOu++TzIuIPkI6d4nblOwuEF6OkG?= =?Windows-1252?Q?Bn53i33A72lScx464eIYVL79KPo90jqGpb4A9yp8VV9IWqZOy/l6kW7R?= =?Windows-1252?Q?jScOYQnGIm5r61AqgPgistjbFrhMuq+wxnTZu7GRwOzB8hwN7YsY7246?= =?Windows-1252?Q?wImdqS3F2WXe1ICDDvjoGBleDcO6xq6UdQs+cKM5AG5N+Bp47QdfS+7U?= =?Windows-1252?Q?dl01ZG1Ea3fticMWtxSGWfJfbOJg/EHj1ne/FZ+nxk3pZPlQ5dE7JUGV?= =?Windows-1252?Q?rwn18KlJzShcd4lTtYZ+Cy6nS89X1tOY1IhRdFofJNpVX5rTCO7y/uI3?= =?Windows-1252?Q?YFK786BTkVEaGizTG3PdomNWZY1sdLiMCWV7wFc1iZTCF3GV24F6zQnx?= =?Windows-1252?Q?2r6sacLIMsJkxAE2ZD2OLMXCWmDXM5hdfKlwErIslUQgznkZOe9CtoVG?= =?Windows-1252?Q?d19VFv9rOQ0KH58rUi4ZHXhBdFDNkvhidDznLVYuEQBA8jsV/AvXbu/0?= =?Windows-1252?Q?nI/bTmz/FmicqlJV1AFpRU/RW8FOxAHjwSEegyRmarB6xK+AQW2+uM77?= =?Windows-1252?Q?ZJuA8RDCYGf7JvLEkk0vU/ULgZTRyzJbWv08xtMmHTRUv16Mq6FjVgMi?= =?Windows-1252?Q?QoPLkEPvcF28jz+4vD6U+c1yufK0Gaqpl+tTiAoSWf9sTuZgja0EqygB?= =?Windows-1252?Q?2u26FN+/ociuTXdOfP7deGvbYlGIR2VmoqKr0UbTIMGQKbStJ6dmbNdR?= =?Windows-1252?Q?DveGdB4Cms4tQrL2rsCYcHUWkRLBz62BcI5nsUhl9Ou99cWhbwT2UxOU?= =?Windows-1252?Q?vGgg+Hm7bU3/K2XU1RWMDrCk/p5ElFBKtv7IbUIyJ6G4aerBQhHtMDTu?= =?Windows-1252?Q?7vSSoBGrtWZMqCB7uUw0aICPjOLqv50tq4Qc+CGhbZ6nAaQ0G0bjhJW/?= =?Windows-1252?Q?5tnwukj/hEZ+/yNVZ7tDSnqeQkPCV/CbXoSZCGGGBpdhymgeXM4K4r25?= =?Windows-1252?Q?DSX0+Loo2llPV5o9FEQtY+MTf6YQWjAFePsDSBOH+jNQP7tNgJ1q1OTD?= =?Windows-1252?Q?vaqTgvWHWZqM/+FLtpFuJWUNRQqLATc3UDTVMAfgxj7bs03phAGv8IUg?= =?Windows-1252?Q?ysUZmUWkLjS5en32AiKHojNqJ1C+J7mV?= Content-Type: multipart/alternative; boundary="_000_PR0P264MB07941B6AF99182D1CE404018C0BA9PR0P264MB0794FRAP_" MIME-Version: 1.0 X-OriginatorOrg: trust-in-soft.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PR0P264MB0794.FRAP264.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-Network-Message-Id: 9f272f41-be39-4a4d-3da6-08db2139e28d X-MS-Exchange-CrossTenant-originalarrivaltime: 10 Mar 2023 07:34:30.0504 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: c0bee27e-6b2c-476e-88fe-f5a620006e7f X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: cuUOzHCvauYIb3tK0cfQcyauODRY+xGZixTzxYDngFR574C44mLgax0UDYSoKtgkyWVCL1QWg/xXGzHVJZRu5Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR0P264MB1545 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,HTML_MESSAGE,KAM_SHORT,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: --_000_PR0P264MB07941B6AF99182D1CE404018C0BA9PR0P264MB0794FRAP_ Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable Hello, I do not feel confident sending a patch for the following reason: Glibc commit 85422c2acba83852396c9d9fd22ff0493e3606fe does contain a partia= l description of the specification that Glibc strives to implement: This patch makes them do so in cases that should include all the cases where such errno setting is required by glibc's goals for when to set errno (but not all cases of underflow where the result is nonzero and so glibc's goals do not require errno setting). However much remains unclear (for me!) about the specification that Glibc s= trives to implement. Does this mean that the specification is actually non-= deterministic and that the manpage should contain a sentence saying =93when= the result of nextafter applied to distinct arguments x and y is subnormal= , nextafter reserves the right to set errno to ERANGE but offers not guaran= tees of doing so; if the result is zero, errno is guaranteed to be set to E= RANGE=94? This does not make sense to me: how does one choose one's own spe= cification for nextafter, over which one has full control, for a basic func= tion that does not need to allocate resources, and make this specification = non-deterministic? Does the non-determinism apply to the floating-point und= erflow exception as well? But then again, I notice that the current manpage description is already no= n-deterministic: a result that should be subnormal can be 0.0, confirming t= hat I do not understand Glibc's goals. In these conditions I could not do a= good job describing the specification that Glibc implements. Pascal ________________________________ From: Alejandro Colomar Sent: Friday, March 10, 2023 01:51 To: Pascal Cuoq; mtk.manpages@gmail.com Cc: linux-man@vger.kernel.org; Guillaume Cluzel; GNU C Library; Andreas Sch= wab Subject: Re: nextafter underflow and errno in Glibc Hello Pascal, On 3/8/23 19:10, Pascal Cuoq wrote: > Hello, > > in 2008 Michael Kerrisk reported that Glibc's nextafter implementation di= d not set errno as it should: > > https://sourceware.org/bugzilla/show_bug.cgi?id=3D6799 > > That bug was marked as =93RESOLVED FIXED=94 in 2020 but there still exist= s a disagreement between what the current man page for nextafter at https:/= /man7.org/linux/man-pages/man3/nextafter.3.html says, namely: > > If x is not equal to y, and the correct function result would be > subnormal, zero, or underflow, a range error occurs, and either > the correct value (if it can be represented), or 0.0, is > returned. > =85 > Range error: result is subnormal or underflows > errno is set to ERANGE. An underflow floating-point > exception (FE_UNDERFLOW) is raised. > > =85 and what Glibc's implementation does for nextafter(0., 1.). > > This has been reported by myself in January of 2023: > > https://sourceware.org/bugzilla/show_bug.cgi?id=3D30040 > > As of this writing, the Glibc maintainers' stance appears to be that this= behavior is intentional because the specification that Glibc intends to im= plement only mandates setting errno when the result is zero, and apparently= allows setting it or not when the result is 0x1.0p-1074, depending on whet= her this value was obtained by going one step up from 0.0 or one step down = from 0x2.0p-1074. > > If the Glibc maintainers do not consider the current behavior a bug, then= this should be noted somehow in the nextafter man page. Would you please send a patch for the manual page? You can find the guidelines for that here: . You can clone the git repository from here: If you send a patch, please CC the folowing: Cc: Andreas Schwab Cc: Thanks, Alex > > Regards, > > Pascal > -- GPG key fingerprint: A9348594CE31283A826FBDD8D57633D441E25BB5 --_000_PR0P264MB07941B6AF99182D1CE404018C0BA9PR0P264MB0794FRAP_--