From: | jian he <jian(dot)universality(at)gmail(dot)com> |
---|---|
To: | Andres Freund <andres(at)anarazel(dot)de> |
Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)lists(dot)postgresql(dot)org |
Subject: | Re: gcc 15 "array subscript 0" warning at level -O3 |
Date: | 2025-07-02 14:13:17 |
Message-ID: | CACJufxFZ5Bb93=c0aQ+u4b94auYcOdhRnNQHkV7ASpTX1uzW+A@mail.gmail.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Thu, Jun 5, 2025 at 3:00 AM Andres Freund <andres(at)anarazel(dot)de> wrote:
>
> > > The dereference is not reachable
> > > because of the preceding "var->datatype->typlen == -1" check,
> > > but that's not stopping the optimizer from bitching.
> >
> > > I experimented with modifying exec_set_found thus:
> > >
> > > var = (PLpgSQL_var *) (estate->datums[estate->found_varno]);
> > > + Assert(var->datatype->typlen == 1);
> > > assign_simple_var(estate, var, BoolGetDatum(state), false, false);
> > >
> > > which should be OK since we're expecting the "found" variable to
> > > be boolean. That does silence the warning, but of course only
> > > in --enable-cassert builds.
> >
> > One way to address this is outlined here:
> >
> > https://postgr.es/m/20230316172818.x6375uvheom3ibt2%40awork3.anarazel.de
> > https://postgr.es/m/20240207203138.sknifhlppdtgtxnk%40awork3.anarazel.de
> >
> > I've been wondering about adding wrapping something like that in a
> > pg_assume(expr) or such.
>
> I've been once more annoyed by this warning. Here's a prototype for the
> approach outlined above.
>
I can confirm the warning disappears when using gcc-14.0 compile
source code with the attached patch.
I didn't review it though.
I didn’t find this in the CommitFest, so I added an entry [1] to make sure it
doesn’t get forgotten...
From | Date | Subject | |
---|---|---|---|
Next Message | Fujii Masao | 2025-07-02 14:15:09 | Re: Add progressive backoff to XactLockTableWait functions |
Previous Message | Dagfinn Ilmari Mannsåker | 2025-07-02 14:09:26 | Re: [PATCH] initdb: Treat empty -U argument as unset username |