Re: New compiler warning

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: David Steele <david(at)pgmasters(dot)net>
Cc: Aleksander Alekseev <aleksander(at)timescale(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, Peter Eisentraut <peter(at)eisentraut(dot)org>
Subject: Re: New compiler warning
Date: 2023-08-30 16:06:42
Message-ID: ZO9pEvWNgqOtbwrA@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


Peter Eisentraut has applied a patch to fix this.

---------------------------------------------------------------------------

On Wed, Aug 30, 2023 at 10:07:24AM -0400, David Steele wrote:
> On 8/30/23 08:10, Aleksander Alekseev wrote:
> >
> > > I am seeing a new gcc 12.2.0 compiler warning from
> > > src/backend/commands/sequence.c:
> >
> > Yep, the compiler is just not smart enough to derive that this
> > actually is not going to happen.
> >
> > Here is a proposed fix.
>
> Here's an alternate way to deal with this which is a bit more efficient
> (code not tested):
>
> - case SEQ_COL_CALLED:
> - coldef = makeColumnDef("is_called", BOOLOID, -1, InvalidOid);
> - value[i - 1] = BoolGetDatum(false);
> - break;
> + default:
> + Assert(i == SEQ_COL_CALLED);
> + coldef = makeColumnDef("is_called", BOOLOID, -1, InvalidOid);
> + value[i - 1] = BoolGetDatum(false);
> + break;
>
> The downside is that any garbage in i will lead to processing as
> SEQ_COL_CALLED. But things are already pretty bad in that case, ISTM, even
> with the proposed patch (or the original code for that matter).
>
> Regards,
> -David

--
Bruce Momjian <bruce(at)momjian(dot)us> https://momjian.us
EDB https://enterprisedb.com

Only you can decide what is important to you.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Jeff Davis 2023-08-30 16:09:43 Re: [17] CREATE SUBSCRIPTION ... SERVER
Previous Message Bruce Momjian 2023-08-30 15:34:22 Re: Debian 12 gcc warning