Re: patch: Use pg_assume in jsonb_util.c to fix GCC 15 warnings - Mailing list pgsql-hackers

From Peter Geoghegan
Subject Re: patch: Use pg_assume in jsonb_util.c to fix GCC 15 warnings
Date
Msg-id CAH2-WzkXwnY=cNGDODOyW=AhT4H8Rj7MiOk3mcN=Ua2w8C=RZg@mail.gmail.com
Whole thread Raw
In response to Re: patch: Use pg_assume in jsonb_util.c to fix GCC 15 warnings  (Andres Freund <andres@anarazel.de>)
Responses Re: patch: Use pg_assume in jsonb_util.c to fix GCC 15 warnings
Re: patch: Use pg_assume in jsonb_util.c to fix GCC 15 warnings
List pgsql-hackers
On Sat, Jul 12, 2025 at 1:55 PM Andres Freund <andres@anarazel.de> wrote:
> I had played with using pg_assume here too, but I couldn't really convince
> myself that it's a good idea...

In the past, it was often necessary to work around MSVC's inability to
see that a block containing elog(ERROR) doesn't actually need to
initialize variables that'll never actually be used in code that comes
after that block. We still have many "keep compiler quiet" variable
initializations due to this.

Is that still something that we need to worry about? I don't recall
running into it in quite a few years, though that might just be a
coincidence.

It looks like MSVC uses __assume for this now, by way of
elog/ereport's use of pg_unreachable. You also used __assume to
implement pg_assume for MSVC. It seems reasonable to surmise that we
can officially stop worrying about elog(ERROR) related warnings/to
suppose that we no longer have to add "keep compiler quiet" variable
initializations after an elog(ERROR). If it works for MSVC +
pg_assume, then it ought to also work for MSVC + pg_unreachable.
Right?

--
Peter Geoghegan



pgsql-hackers by date:

Previous
From: Jacob Champion
Date:
Subject: Re: libpq: Process buffered SSL read bytes to support records >8kB on async API
Next
From: Jack Ng
Date:
Subject: RE: Changing shared_buffers without restart