BUG #16790: Integer overflow not detected with <<

Поиск
Список
Период
Сортировка
От PG Bug reporting form
Тема BUG #16790: Integer overflow not detected with <<
Дата
Msg-id 16790-c2a81c92a8776c5b@postgresql.org
обсуждение исходный текст
Ответы Re: BUG #16790: Integer overflow not detected with <<
Список pgsql-bugs
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.)


В списке pgsql-bugs по дате отправления:

Предыдущее
От: Michael Paquier
Дата:
Сообщение: Re: CREATE INDEX CONCURRENTLY does not index prepared xact's data
Следующее
От: Tom Lane
Дата:
Сообщение: Re: BUG #16790: Integer overflow not detected with <<