Re: [PATCH] intXshr, intXshl: return error on shift count out of range

From: Alexander Lakhin <exclusion(at)gmail(dot)com>
To: Pavel Borisov <pashkin(dot)elfe(at)gmail(dot)com>, Egor Ivkov <e(dot)ivkov(at)arenadata(dot)io>
Cc: "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Ilya Khaprov <i(dot)khaprov(at)arenadata(dot)io>
Subject: Re: [PATCH] intXshr, intXshl: return error on shift count out of range
Date: 2026-09-30 19:00:00
Message-ID: 1a2cd55f-159a-452e-9d70-9e8f2bd1faa7@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello Egor and Pavel,

30.09.2026 17:28, Pavel Borisov wrote:
>> Small fix for .out files to contain rightmost spaces.
>>
>> Regards,
>> Egor Ivkov
> Your patch looks good to me except the similar behavior of int2 and
> int4 are never explained. In C11 and older int16 left arg bit shift
> is not UB only if the result filts int32. There is no check for this
> in the patch.

FWIW, this was already reported several times:
[1] https://www.postgresql.org/message-id/48099055.9040607%40dls.net
[2] https://www.postgresql.org/message-id/16790-c2a81c92a8776c5b%40postgresql.org
[3] https://www.postgresql.org/message-id/17167-028026e4ca333817%40postgresql.org
[4] https://www.postgresql.org/message-id/19672-33e7d9d1be2229ea%40postgresql.org

By the way, having a RISC-V machine handy:
Linux orangepirv2 6.6.63-ky #1.0.0 SMP PREEMPT Wed Mar 12 09:04:00 CST 2025 riscv64 riscv64 riscv64 GNU/Linux
I've tried:
SELECT int4shl(1, 100);
 int4shl
---------
      16
(1 row)

Best regards,
Alexander

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message David G. Johnston 2026-09-30 19:13:31 Re: Document that jsonpath == can be used as ANY
Previous Message Marcos Pegoraro 2026-09-30 18:47:25 Re: Document that jsonpath == can be used as ANY