Re: Avoid undefined behavior with msvc compiler (src/include/port/pg_bitutils.h)

From: John Naylor <john(dot)naylor(at)enterprisedb(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Ranier Vilela <ranier(dot)vf(at)gmail(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Avoid undefined behavior with msvc compiler (src/include/port/pg_bitutils.h)
Date: 2023-07-31 11:55:16
Message-ID: CAFBsxsFB74gMn+yMvo=ApX=_hyPcnyz7nkRy5Fn13=+cBA63FQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Jul 31, 2023 at 5:57 PM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>
> John Naylor <john(dot)naylor(at)enterprisedb(dot)com> writes:

> > Works for me, so done that way for both forward and reverse variants.
Since
> > the return value is no longer checked in any builds, I thought about
> > removing the variable containing it, but it seems best to leave it
behind
> > for clarity since these are not our functions.
>
> Hmm, aren't you risking "variable is set but not used" warnings?
> Personally I'd have made these like
>
> (void) _BitScanReverse(&result, word);

I'd reasoned that such a warning would have showed up in non-assert builds
already, but I neglected to consider that those could have different
warning settings. For the time being drongo shows green, at least, but
we'll see.

--
John Naylor
EDB: http://www.enterprisedb.com

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Masahiko Sawada 2023-07-31 12:03:07 Re: stats test intermittent failure
Previous Message Tomas Vondra 2023-07-31 11:34:47 Re: logical decoding and replication of sequences, take 2