Re: Avoid undefined behavior with msvc compiler (src/include/port/pg_bitutils.h)

Поиск
Список
Период
Сортировка
От John Naylor
Тема Re: Avoid undefined behavior with msvc compiler (src/include/port/pg_bitutils.h)
Дата
Msg-id CAFBsxsFph6BoRB8PwZxbHQCx9+=hAcF9tk1_Xh=ichq7hMzC6A@mail.gmail.com
обсуждение исходный текст
Ответ на Avoid undefined behavior with msvc compiler (src/include/port/pg_bitutils.h)  (Ranier Vilela <ranier.vf@gmail.com>)
Ответы Re: Avoid undefined behavior with msvc compiler (src/include/port/pg_bitutils.h)
Список pgsql-hackers

On Sat, Jul 29, 2023 at 7:37 PM Ranier Vilela <ranier.vf@gmail.com> wrote:
>
> Hi,
>
> The pg_leftmost_one_pos32 function with msvc compiler,
> relies on Assert to guarantee the correct result.
>
> But msvc documentation [1] says clearly that
> undefined behavior can occur.

It seems that we should have "Assert(word != 0);" at the top, which matches the other platforms anyway, so I'll add that.

> Fix by checking the result of the function to avoid
> a possible undefined behavior.

No other platform does this, and that is by design. I'm also not particularly impressed by the unrelated cosmetic changes.

--
John Naylor
EDB: http://www.enterprisedb.com

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

Предыдущее
От: Nathan Bossart
Дата:
Сообщение: Re: Faster "SET search_path"
Следующее
От: "Andrey M. Borodin"
Дата:
Сообщение: Re: UUID v7