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

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: David Rowley <dgrowleyml(at)gmail(dot)com>
Cc: Egor Ivkov <e(dot)ivkov(at)arenadata(dot)io>, "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 22:55:16
Message-ID: 1034484.1790808916@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

David Rowley <dgrowleyml(at)gmail(dot)com> writes:
> Have you actually tested this on RISC-V? Can you share the results of:
> SELECT 1::bigint << 255, 1::bigint << 63;
> Does it actually crash?

I tried this on the gcc compile farm's cfarm95 (said to be
a Banana Pi BPI-F3 with Spacemit(R) X60 chip; runs Debian trixie).
I see no crash and results consistent with the low-six-bits rule:

regression=# SELECT 1::bigint << 255, 1::bigint << 63;
?column? | ?column?
----------------------+----------------------
-9223372036854775808 | -9223372036854775808
(1 row)

regression=# SELECT 1::bigint << 64, 1::bigint << (-1);
?column? | ?column?
----------+----------------------
1 | -9223372036854775808
(1 row)

I rather imagine you can make it crash if you use ASAN configured to
dump core on whatever behavior it considers undefined ... but I
reject the notion that we should let ASAN dictate our choices here.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2026-09-30 22:55:52 Re: injection_points: canceled or terminated waiters leak their wait slots
Previous Message David Rowley 2026-09-30 22:23:57 Re: [PATCH] intXshr, intXshl: return error on shift count out of range