Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ks65S-0006E3-FA for pgsql-bugs@arkaria.postgresql.org; Wed, 23 Dec 2020 15:30:02 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ks65R-0002k8-8M for pgsql-bugs@arkaria.postgresql.org; Wed, 23 Dec 2020 15:30:01 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ks65R-0002k0-2H for pgsql-bugs@lists.postgresql.org; Wed, 23 Dec 2020 15:30:01 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ks65P-0007QQ-0b for pgsql-bugs@lists.postgresql.org; Wed, 23 Dec 2020 15:30:00 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 0BNFTutJ710064; Wed, 23 Dec 2020 10:29:56 -0500 From: Tom Lane To: exclusion@gmail.com cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #16790: Integer overflow not detected with << In-reply-to: <16790-c2a81c92a8776c5b@postgresql.org> References: <16790-c2a81c92a8776c5b@postgresql.org> Comments: In-reply-to PG Bug reporting form message dated "Wed, 23 Dec 2020 09:00:01 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <710062.1608737396.1@sss.pgh.pa.us> Date: Wed, 23 Dec 2020 10:29:56 -0500 Message-ID: <710063.1608737396@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk PG Bug reporting form writes: > It seems that the bitwise shift left operator ignores overflow: > 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.) It's defined to do whatever the C << operator does. That will certainly not involve throwing an error. regards, tom lane