Re: [PATCH] intXshr, intXshl: return error on shift count out of range - Mailing list pgsql-hackers

From Alexander Lakhin
Subject Re: [PATCH] intXshr, intXshl: return error on shift count out of range
Date
Msg-id 1a2cd55f-159a-452e-9d70-9e8f2bd1faa7@gmail.com
Whole thread
In response to Re: [PATCH] intXshr, intXshl: return error on shift count out of range  (Pavel Borisov <pashkin.elfe@gmail.com>)
Responses Re: [PATCH] intXshr, intXshl: return error on shift count out of range
List 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

pgsql-hackers by date:

Previous
From: Marcos Pegoraro
Date:
Subject: Re: Document that jsonpath == can be used as ANY
Next
From: "David G. Johnston"
Date:
Subject: Re: Document that jsonpath == can be used as ANY