Re: fix for strict-alias warnings

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: fix for strict-alias warnings
Дата
Msg-id 11885.1066159891@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: fix for strict-alias warnings  (Manfred Spraul <manfred@colorfullife.com>)
Ответы Re: fix for strict-alias warnings  (Bruce Momjian <pgman@candle.pha.pa.us>)
Re: fix for strict-alias warnings  (Peter Eisentraut <peter_e@gmx.net>)
Re: fix for strict-alias warnings  (Manfred Spraul <manfred@colorfullife.com>)
Список pgsql-patches
Manfred Spraul <manfred@colorfullife.com> writes:
> I've asked the question on the gcc devel list. The first reply was that
> MemSet violates strict aliasing rules:

No doubt it does, but that is not really the issue here; the issue IMHO
is whether there is any real risk involved.  Remember that the macro is
really of the form

    if (blah blah)
    {
        // unsafe code is here
    }
    else
    {
        memset(...);
    }

Given that gcc is smart enough not to move any code across the memset()
call, I doubt that it would be moving anything across the whole if()
construct.  Now if the if-condition were such that the memset code path
could be optimized away, then we'd have a problem, but in practice I do
not believe gcc is smart enough to realize that the alignment check is
always true.

We do have to be wary of MemSetAligned and MemSetLoop, but these are
only used in constrained places (routines that do nothing else with
the memory in question) so I think they are not a problem.

> I think we must either add -fno-strict-aliasing, or switch to the c
> compiler memset functions for gcc.

We will not be doing the latter, for certain.

            regards, tom lane

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

Предыдущее
От: Neil Conway
Дата:
Сообщение: Re: fix for strict-alias warnings
Следующее
От: Bruce Momjian
Дата:
Сообщение: Re: fix for strict-alias warnings