Re: same-address mappings vs. relative pointers

Поиск
Список
Период
Сортировка
От Andres Freund
Тема Re: same-address mappings vs. relative pointers
Дата
Msg-id 20131211114935.GA24772@awork2.anarazel.de
обсуждение исходный текст
Ответ на Re: same-address mappings vs. relative pointers  (Florian Pflug <fgp@phlo.org>)
Список pgsql-hackers
On 2013-12-11 12:37:56 +0100, Florian Pflug wrote:
> On Dec11, 2013, at 11:47 , Andres Freund <andres@2ndquadrant.com> wrote:
> > On 2013-12-11 11:42:25 +0100, Florian Pflug wrote:
> > Yes (although there's C11 stuff to do equivalent stuff afair) - I was
> > thinking of only doing it for compilers we support that dark magic for
> > and fall back to returning a void* for the others. We'll probably miss a
> > cast or two required on !gcc that way, but it's still likely to be less
> > error prone.
> 
> 
> Would it? For this to catch type mismatches, you'd both need to develop
> on a typeof-supporting compiler *and* don't cast the result of relptr_access().
> But you can't really do that, because the code will then fail on compilers
> which don't support typeof()...

Yea, right.

> What we could do, I guess, is to pass the type to relptr_access() and to
> relptr(), and let the compiler verify that they are the same.

Tom and I actually added a macro that's helpful for that recently:
AssertVariableIsOfType(). With that we should be able to get something
reasonable, failing at compile time, with a useful error message even ;)

Greetings,

Andres Freund

-- Andres Freund                       http://www.2ndQuadrant.com/PostgreSQL Development, 24x7 Support, Training &
Services



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

Предыдущее
От: Florian Pflug
Дата:
Сообщение: Re: same-address mappings vs. relative pointers
Следующее
От: Greg Stark
Дата:
Сообщение: Re: ANALYZE sampling is too good