Re: NULL passed as an argument to memcmp() in parse_func.c

Поиск
Список
Период
Сортировка
От Piotr Stefaniak
Тема Re: NULL passed as an argument to memcmp() in parse_func.c
Дата
Msg-id BLU436-SMTP57ACDE6DDEC80818C4E6CBF2A10@phx.gbl
обсуждение исходный текст
Ответ на Re: NULL passed as an argument to memcmp() in parse_func.c  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: NULL passed as an argument to memcmp() in parse_func.c
Re: NULL passed as an argument to memcmp() in parse_func.c
Список pgsql-hackers
On 06/22/2015 08:55 PM, Tom Lane wrote:
> Are you seeing any observable problem here, and if so what is it?
Not yet; perhaps with GCC 7 or 8...

> If I recall that code correctly, the assumption was that if the third
> argument is zero then memcmp() must not fetch any bytes (not should not,
> but MUST not) and therefore it doesn't matter if we pass a NULL.
It's not about fetching any bytes, it's about passing an invalid pointer 
(a null pointer in this case) which gives a compiler the opportunity to 
apply an optimization. For example, glibc has memcpy marked as 
__nonnull(1,2).

But if you remain unconvinced then I yield.



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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: NULL passed as an argument to memcmp() in parse_func.c
Следующее
От: Tom Lane
Дата:
Сообщение: Re: NULL passed as an argument to memcmp() in parse_func.c