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:26
Message-ID: E1xC6NO-00000001wSt-3vZF@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_15_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/d6896c056d69da2a451e032cd7b9823de299cdfb

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

Browse pgsql-committers by date

  From Date Subject
Next Message David Rowley 2026-10-01 02:18:51 pgsql: Doc: mention platform-dependent behavior of bitshift operators
Previous Message David Rowley 2026-10-01 02:18:04 pgsql: Doc: mention platform-dependent behavior of bitshift operators