Re: bug in function strtoint, on Windows OS won't report ERANGE

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Miron Berlin <mironatpro(at)hotmail(dot)com>
Cc: "pgsql-bugs(at)lists(dot)postgresql(dot)org" <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: bug in function strtoint, on Windows OS won't report ERANGE
Date: 2024-03-05 15:42:11
Message-ID: 4019549.1709653331@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Miron Berlin <mironatpro(at)hotmail(dot)com> writes:
> Functionstrtoint has a bug. It would not report ERANGE on Windows OS compiled 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 != (int) val)
errno = 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

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Alexander Lakhin 2024-03-05 18:00:00 Re: BUG #18351: VACUUM FULL fails with error: missing chunk number 0 for toast value XXX
Previous Message Said Krikess 2024-03-05 14:38:23 Issue with PostgreSQL 11 RPM Package Availability