Re: 64-bit integer subtraction bug on some platforms
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Laurenz Albe <laurenz.albe@cybertec.at>
Cc: Dean Rasheed <dean.a.rasheed@gmail.com>,
PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2023-11-08T16:08:05Z
Lists: pgsql-hackers
Laurenz Albe <laurenz.albe@cybertec.at> writes: > On Wed, 2023-11-08 at 11:58 +0000, Dean Rasheed wrote: >> This should overflow, since the correct result (+9223372036854775808) >> is out of range. However, on platforms without integer overflow >> builtins or 128-bit integers, pg_sub_s64_overflow() does the >> following: >> ... >> which fails to spot the fact that overflow is also possible when a == >> 0. So on such platforms, it returns the wrong result. >> >> Patch attached. > The patch looks good to me. +1: good catch, fix looks correct. regards, tom lane
Commits
-
Fix corner-case 64-bit integer subtraction bug on some platforms.
- b17a02be27e0 12.18 landed
- 4f4a0010a3a1 13.14 landed
- dea12b40d521 14.11 landed
- 308a69a98782 15.6 landed
- c396aca2b712 16.2 landed
- 0e3e8fbd3a8b 17.0 landed