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

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Avoid undefined behavior with msvc compiler (src/include/port/pg_bitutils.h)
Дата
Msg-id 2718294.1690728343@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Avoid undefined behavior with msvc compiler (src/include/port/pg_bitutils.h)  (John Naylor <john.naylor@enterprisedb.com>)
Ответы Re: Avoid undefined behavior with msvc compiler (src/include/port/pg_bitutils.h)
Список pgsql-hackers
John Naylor <john.naylor@enterprisedb.com> writes:
> It seems that we should have "Assert(word != 0);" at the top, which matches
> the other platforms anyway, so I'll add that.

That's basically equivalent to the existing Assert(non_zero).
I think it'd be okay to drop that one and instead have
the same Assert condition as other platforms, but having both
would be redundant.

I agree that adding the non-Assert test that Ranier wants
is entirely pointless.  If a caller did manage to violate
the asserted-for condition (and we don't have asserts on),
returning zero is not better than returning an unspecified
value.  If anything it might be worse, since it might not
lead to obvious misbehavior.

On the whole, there's not anything wrong with the code as-is.
A case could be made for making the MSVC asserts more like
other platforms, but it's quite cosmetic.

            regards, tom lane



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

Предыдущее
От: "Andrey M. Borodin"
Дата:
Сообщение: Re: UUID v7
Следующее
От: "Anton A. Melnikov"
Дата:
Сообщение: Re: odd buildfarm failure - "pg_ctl: control file appears to be corrupt"