Re: strange case of "if ((a & b))"

From: Justin Pryzby <pryzby(at)telsasoft(dot)com>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: strange case of "if ((a & b))"
Date: 2021-08-18 19:23:18
Message-ID: 20210818192318.GS10479@telsasoft.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Aug 18, 2021 at 03:15:21PM -0400, Bruce Momjian wrote:
> On Wed, Aug 18, 2021 at 01:28:56PM -0500, Justin Pryzby wrote:
> > > > 0002 is a bonus patch I found in my typos branch. I will hold onto it for
> > > > later if nobody wants to deal with it.
> > >
> > > I am ready to deal with this patch. Should I apply it to master soon?
> >
> > Thanks for looking at it. I suggest not to apply 0002 - I'll resend it on
> > another thread with other, similar cleanups.
>
> OK.
>
> > However, I have another patch to clean up stuff like "? true : false", which
> > seems related to this patch (but maybe it should be applied separately).
>
> Yes, that is odd. I think it is related to the confusion that if ()
> compares non-zero(true) and zero(false), while booleans return only 1/0
> (no other values). This explores that:
>
> https://stackoverflow.com/questions/22489517/c-language-boolean-expression-return-value
>
> Do you want me to consider this patch now?

Yes, please.
It may be helpful to dispose of the first patch first.

Thanks,
Justin

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Geoghegan 2021-08-18 19:58:27 Re: The Free Space Map: Problems and Opportunities
Previous Message Bruce Momjian 2021-08-18 19:15:21 Re: strange case of "if ((a & b))"