pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: David Rowley <drowley@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Doc: mention platform-dependent behavior of bitshift operators
Date: Thu, 01 Oct 2026 02:18:26 +0000
Message-ID: <E1xC6NO-00000001wSt-3vZF@gemulon.postgresql.org> (raw)

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@gmail.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.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(+)



view thread (7+ messages)  latest in thread

Message-ID: <E1xC6NO-00000001wSt-3vZF@gemulon.postgresql.org>
Permalink:  ../E1xC6NO-00000001wSt-3vZF@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1xC6NO-00000001wSt-3vZF@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: drowley@postgresql.org
  Subject: Re: pgsql: Doc: mention platform-dependent behavior of bitshift operators
  In-Reply-To: <E1xC6NO-00000001wSt-3vZF@gemulon.postgresql.org>
  References: <E1xC6NO-00000001wSt-3vZF@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox