From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: exclusion@gmail.com
Subject: BUG #16790: Integer overflow not detected with <<
Date: Wed, 23 Dec 2020 09:00:01 +0000
Message-ID: <16790-c2a81c92a8776c5b@postgresql.org> (raw)
The following bug has been logged on the website:
Bug reference: 16790
Logged by: Alexander Lakhin
Email address: exclusion@gmail.com
PostgreSQL version: 13.1
Operating system: Ubuntu 20.04
Description:
It seems that the bitwise shift left operator ignores overflow:
SELECT -1::int4<<32;
-1
But:
SELECT (-1::int4<<31) * 2;
ERROR: integer out of range
Is this an expected behavior (a kind of UB)? It's not like an arithmetic
shift. (The semantic of '1::int4<<-1' is questionable too.)
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 using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: noreply@postgresql.org, pgsql-bugs@lists.postgresql.org, exclusion@gmail.com
Subject: Re: BUG #16790: Integer overflow not detected with <<
In-Reply-To: <16790-c2a81c92a8776c5b@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