Re: gcc 15 "array subscript 0" warning at level -O3
От | jian he |
---|---|
Тема | Re: gcc 15 "array subscript 0" warning at level -O3 |
Дата | |
Msg-id | CACJufxFZ5Bb93=c0aQ+u4b94auYcOdhRnNQHkV7ASpTX1uzW+A@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: gcc 15 "array subscript 0" warning at level -O3 (Andres Freund <andres@anarazel.de>) |
Список | pgsql-hackers |
On Thu, Jun 5, 2025 at 3:00 AM Andres Freund <andres@anarazel.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... [1]: https://commitfest.postgresql.org/patch/5888/
В списке pgsql-hackers по дате отправления: