Re: new warnings with clang-21 / how const is Datum
Peter Eisentraut <peter@eisentraut.org>
From: Peter Eisentraut <peter@eisentraut.org>
To: pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2025-09-08T12:01:20Z
Lists: pgsql-hackers
Attachments
- 0001-Silence-compiler-warning-on-clang-21.patch (text/plain) patch 0001
- 0002-Some-stylistic-improvements-in-toast_save_datum.patch (text/plain) patch 0002
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.
Commits
-
Some stylistic improvements in toast_save_datum()
- 748caa9dcb68 19 (unreleased) landed
-
Silence compiler warnings on clang 21
- 385c5dfe24de 16.11 landed
- a399db8d5988 17.7 landed
- 14bb47567a39 18.0 landed
- e92677e86333 19 (unreleased) landed
-
Convert *GetDatum() and DatumGet*() macros to inline functions
- c8b2ef05f481 16.0 cited