Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rhWw1-00BwwA-KU for pgsql-bugs@arkaria.postgresql.org; Tue, 05 Mar 2024 15:42:30 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rhWvy-000QF5-Ij for pgsql-bugs@arkaria.postgresql.org; Tue, 05 Mar 2024 15:42:27 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rhWvy-000QEx-A8 for pgsql-bugs@lists.postgresql.org; Tue, 05 Mar 2024 15:42:26 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rhWvr-002uzr-AI for pgsql-bugs@lists.postgresql.org; Tue, 05 Mar 2024 15:42:25 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 425FgBF64019550; Tue, 5 Mar 2024 10:42:11 -0500 From: Tom Lane To: Miron Berlin cc: "pgsql-bugs@lists.postgresql.org" Subject: Re: bug in function strtoint, on Windows OS won't report ERANGE In-reply-to: References: Comments: In-reply-to Miron Berlin message dated "Tue, 05 Mar 2024 12:15:26 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <4019548.1709653331.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Tue, 05 Mar 2024 10:42:11 -0500 Message-ID: <4019549.1709653331@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Miron Berlin writes: > Functionstrtoint has a bug. It would not report ERANGE on Windows OS com= piled with Microsoft Visual Studio compiler. Have you actually tested that? AFAICS, the code as given works perfectly fine on platforms where long is the same width as int. The lines if (val !=3D (int) val) errno =3D ERANGE; are dead code then (and possibly will be elided by the compiler), but it doesn't matter because then strtol can be expected to set ERANGE properly for values outside the int range. Possibly it'd be worth adding a comment to point this out. regards, tom lane