pgsql: Doc: mention platform-dependent behavior of bitshift operators

From: David Rowley <drowley(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Doc: mention platform-dependent behavior of bitshift operators
Date: 2026-10-01 02:18:51
Message-ID: E1xC6Nn-00000001wUL-3j8z@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Doc: mention platform-dependent behavior of bitshift operators

There have been several recent complaints that << and >> don't behave
the same way on all supported platforms. There is a risk that <<
overflows the signed integer type, which is undefined behavior, and there
are platform-dependent behaviors from shifting by numbers of bits >= the
bitwidth of the type, and also from shifting by negative values.

Document this to warn unsuspecting users of these facts.

Author: David Rowley <dgrowleyml(at)gmail(dot)com>
Reviewed-by: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Discussion: https://postgr.es/m/CAApHDvr0O6ZF8NO=Rq9Q+Sz=FHT=NZ1kkNTXZDcNph-OWuk7TQ@mail.gmail.com
Backpatch-through: 14

Branch
------
REL_14_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/2028d62f3e79f2425d87d9f431c75d6f84bda06e

Modified Files
--------------
doc/src/sgml/func.sgml | 7 +++++++
1 file changed, 7 insertions(+)

Browse pgsql-committers by date

  From Date Subject
Next Message Masahiko Sawada 2026-10-01 12:53:52 pgsql: Stabilize repack_decode isolation test.
Previous Message David Rowley 2026-10-01 02:18:26 pgsql: Doc: mention platform-dependent behavior of bitshift operators