Re: [HACKERS] taking stdbool.h into use

Поиск
Список
Период
Сортировка
От Alvaro Herrera
Тема Re: [HACKERS] taking stdbool.h into use
Дата
Msg-id 20171026224833.at7qeyb3n7vrttes@alvherre.pgsql
обсуждение исходный текст
Ответ на Re: [HACKERS] taking stdbool.h into use  (Michael Paquier <michael.paquier@gmail.com>)
Ответы Re: [HACKERS] taking stdbool.h into use  (Michael Paquier <michael.paquier@gmail.com>)
Re: [HACKERS] taking stdbool.h into use  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
Michael Paquier wrote:
> On Thu, Oct 26, 2017 at 10:51 AM, Alvaro Herrera
> <alvherre@alvh.no-ip.org> wrote:
> > I gave this a quick run, to see if my compiler would complain for things
> > like this:
> >
> >    bool        isprimary = flags & INDEX_CREATE_IS_PRIMARY;
> >
> > (taken from the first patch at
> > https://postgr.es/m/20171023161503.ohkybquxrlech7d7@alvherre.pgsql )
> >
> > which is assigning a value other than 1/0 to a bool variable without an
> > explicit cast.  I thought it would provoke a warning, but it does not.
> > Is that expected?  Is my compiler too old/new?
> 
> It seems to me that this proves the point of the proposed patch. You
> had better use a zero-equality comparison for such bitwise operation,
> and so you ought to do that:
> bool        isprimary = (flags & INDEX_CREATE_IS_PRIMARY) != 0;

Right, exactly.  But my point is that with the whole patch series
applied I didn't get any warnings.

-- 
Álvaro Herrera                https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

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

Предыдущее
От: Jeff Janes
Дата:
Сообщение: [HACKERS] bgwriter_lru_maxpages range in postgresql.conf
Следующее
От: Michael Paquier
Дата:
Сообщение: Re: [HACKERS] taking stdbool.h into use