Re: [PATCH] gcc warning 'expression which evaluates to zero treatedas a null pointer'

Поиск
Список
Период
Сортировка
От didier
Тема Re: [PATCH] gcc warning 'expression which evaluates to zero treatedas a null pointer'
Дата
Msg-id CAJRYxuKAOOPrxb6QUYAQ6yBprf6fGOrV-QninFiqT8Jdo8=UXw@mail.gmail.com
обсуждение исходный текст
Ответ на Re: [PATCH] gcc warning 'expression which evaluates to zero treated as a null pointer'  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: [PATCH] gcc warning 'expression which evaluates to zero treated as a null pointer'
Список pgsql-hackers
Hi,
On Wed, Nov 13, 2019 at 8:52 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
>
> didier <did447@gmail.com> writes:
> > Trivial patch:
> > - remove a gcc warning (since commit 7a0574b5)
> > expression which evaluates to zero treated as a null pointer constant of
> >       type 'HeapTuple' (aka 'struct HeapTupleData *')
>
> Hmm, the initializations "HeapTuple newtuple = false" are certainly
> bogus-looking and not per project style; I wonder who's to blame for
> those?  (I do not see what 7a0574b5 would have had to do with it;
> that didn't affect any backend code.)

My mistake it's not gcc but clang for JIT, maybe because it could
change false definition?
clang version: 6.0.0-1ubuntu2
clang -E output before 7a0574b5
HeapTuple newtuple = 0;
with 7a0574b5
HeapTuple newtuple = ((bool) 0);

>
> > - always use "if (newtuple == NULL)" rather than mixing !newtuple and
> > newtuple == NULL
>
> Don't particularly agree with these changes though.  "if (!ptr)" is
> a very common C idiom, and no programmer would tolerate a compiler
> that warned about it.
There's no warning, it's stylistic. In the same function there's both
forms a couple of lines apart: "if (!ptr)" follow by "if (ptr ==
NULL)", using only one form is smother on the brain, at least mine.

Regards
Didier



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

Предыдущее
От: Tomas Vondra
Дата:
Сообщение: Re: ssl passphrase callback
Следующее
От: Tom Lane
Дата:
Сообщение: Re: [PATCH] gcc warning 'expression which evaluates to zero treated as a null pointer'