| From: | Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com> |
|---|---|
| To: | Imran Zaheer <imran(dot)zhir(at)gmail(dot)com> |
| Cc: | pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Re: Silence -Wmaybe-uninitialized warnings |
| Date: | 2026-04-03 14:47:20 |
| Message-ID: | ac/S+OxBlPPAZaub@ip-10-97-1-34.eu-west-3.compute.internal |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi,
On Fri, Apr 03, 2026 at 07:14:18PM +0500, Imran Zaheer wrote:
> Hi
>
> I pulled the latest HEAD today and found some more -Wmaybe-uninitialized
> warnings.
>
> ```
> [1/6] Compiling C object
> src/interfaces/ecpg/test/pg_regress_ecpg.p/.._.._.._test_regress_pg_regress.c.o
> ../src/test/regress/pg_regress.c: In function ‘results_differ’:
> ../src/test/regress/pg_regress.c:1577:17: warning: ‘startpos’ may be used
> uninitialized in this function [-Wmaybe-uninitialized]
> 1577 | fseek(difffile, startpos, SEEK_SET);
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> [2/6] Compiling C object
> src/test/isolation/pg_isolation_regress.p/.._regress_pg_regress.c.o
> ../src/test/regress/pg_regress.c: In function ‘results_differ’:
> ../src/test/regress/pg_regress.c:1577:17: warning: ‘startpos’ may be used
> uninitialized in this function [-Wmaybe-uninitialized]
> 1577 | fseek(difffile, startpos, SEEK_SET);
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> [3/6] Compiling C object src/test/regress/pg_regress.p/pg_regress.c.o
> ../src/test/regress/pg_regress.c: In function ‘results_differ’:
> ../src/test/regress/pg_regress.c:1577:17: warning: ‘startpos’ may be used
> uninitialized in this function [-Wmaybe-uninitialized]
> 1577 | fseek(difffile, startpos, SEEK_SET);
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ```
>
> Here is the updated v2 patch addressing them.
That's an "old" compiler hallucination.
With an "old" one:
$ gcc -Isrc/backend/postgres_lib.a.p -Isrc/include -I../src/include \
-Og -fPIC -pthread -DBUILDING_DLL -Wmaybe-uninitialized \
-o src/backend/postgres_lib.a.p/partitioning_partbounds.c.o \
-c ../src/backend/partitioning/partbounds.c
../src/backend/partitioning/partbounds.c: In function ‘check_partition_bounds_for_split_range’:
../src/backend/partitioning/partbounds.c:5452:57: warning: ‘datum’ may be used uninitialized in this function [-Wmaybe-uninitialized]
5452 | parser_errposition(pstate, exprLocation((Node *) datum)));
$ gcc --version
gcc (GCC) 11.5.0 20240719 (Red Hat 11.5.0-5)
I can see the same warning that you reported.
But with a more recent one:
/usr/bin/gcc14-gcc -Isrc/backend/postgres_lib.a.p -Isrc/include -I../src/include \
-Og -fPIC -pthread -DBUILDING_DLL -Wmaybe-uninitialized \
-o src/backend/postgres_lib.a.p/partitioning_partbounds.c.o \
-c ../src/backend/partitioning/partbounds.c
There are no warnings.
Regards,
--
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Bertrand Drouvot | 2026-04-03 14:53:15 | meson: Adjust test timeout for Valgrind builds |
| Previous Message | Thomas Munro | 2026-04-03 14:37:26 | Re: pg_waldump: support decoding of WAL inside tarfile |