Re: patch: Use pg_assume in jsonb_util.c to fix GCC 15 warnings

From: Peter Geoghegan <pg(at)bowt(dot)ie>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Dmitry Mityugov <d(dot)mityugov(at)postgrespro(dot)ru>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: patch: Use pg_assume in jsonb_util.c to fix GCC 15 warnings
Date: 2025-07-15 22:35:01
Message-ID: CAH2-WzkXwnY=cNGDODOyW=AhT4H8Rj7MiOk3mcN=Ua2w8C=RZg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sat, Jul 12, 2025 at 1:55 PM Andres Freund <andres(at)anarazel(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jack Ng 2025-07-15 22:52:01 RE: Changing shared_buffers without restart
Previous Message Jacob Champion 2025-07-15 22:31:25 Re: libpq: Process buffered SSL read bytes to support records >8kB on async API