Re: new warnings with clang-21 / how const is Datum

From: Peter Eisentraut <peter(at)eisentraut(dot)org>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: new warnings with clang-21 / how const is Datum
Date: 2025-09-08 12:01:20
Message-ID: 76f41fdc-69e1-43b4-b9aa-503b07980de1@eisentraut.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 01.09.25 08:47, Peter Eisentraut wrote:
> clang-21 shows some new warnings:
>
> ../src/backend/access/common/toast_internals.c:296:33: error: variable
> 'chunk_data' is uninitialized when passed as a const pointer argument
> here [-Werror,-Wuninitialized-const-pointer]
>   296 |         t_values[2] = PointerGetDatum(&chunk_data);
>
> ../src/backend/access/gist/gistutil.c:207:28: error: variable 'attrsize'
> is uninitialized when passed as a const pointer argument here [-Werror,-
> Wuninitialized-const-pointer]
>   207 |                 PointerGetDatum(&attrsize));
>       |                                  ^~~~~~~~
> ../src/backend/access/gist/gistutil.c:276:27: error: variable 'dstsize'
> is uninitialized when passed as a const pointer argument here [-Werror,-
> Wuninitialized-const-pointer]
>   276 |  PointerGetDatum(&dstsize));
>       |                   ^~~~~~~

Here is a quick-fix patch for this. It silences these warnings by
initializing the respective variables first. This is already done
similarly in nearby code. This can be backpatched to PG16, where these
warnings began.

The second patch is a bit of a more extensive code rearrangement to make
the need for the workaround in the first patch go away. This would be
for master only.

Attachment Content-Type Size
0001-Silence-compiler-warning-on-clang-21.patch text/plain 2.1 KB
0002-Some-stylistic-improvements-in-toast_save_datum.patch text/plain 3.2 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Álvaro Herrera 2025-09-08 12:01:42 Re: NOT NULL NOT ENFORCED
Previous Message Vivek Gadge 2025-09-08 11:39:21 Re: Query Performance Degradation Due to Partition Scan Order – PostgreSQL v17.6