Fix warning: ‘startpos’ may be used uninitialized in function ‘results_differ’

From: m(dot)litsarev(at)postgrespro(dot)ru
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Fix warning: ‘startpos’ may be used uninitialized in function ‘results_differ’
Date: 2026-06-11 15:08:13
Message-ID: ee06f058c626cd37babd8c81579ffb1e@postgrespro.ru
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi, hackers!

I found warning while compiling the code (introduced in
5720ae01436480c1dcdd34ece0c3d83b00844bca)
with the folloing message

postgres/build/../src/test/regress/pg_regress.c: In function
‘results_differ’:
postgres/build/../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);

gcc (Ubuntu 11.5.0-10ubuntu1~22~ppa1) 11.5.0
ldd (Ubuntu GLIBC 2.35-0ubuntu3.13) 2.35

./configure --enable-debug --enable-cassert --enable-depend
--enable-tap-tests --enable-nls --with-perl --with-icu --with-libxml
--with-libxslt --with-gssapi --with-openssl --with-zstd --with-lz4
--with-ldap --with-python --prefix=$PGINSTDIR --with-pgport=$PGPORT

CFLAGS="-ggdb -Og -g3 -fno-omit-frame-pointer -fvisibility=default
-Wno-clobbered"

It definitely seems false-positive from semantical point of view, but to
keep compiler silent I attached a small patch which fixes it.

Respectfully,
Mikhail Litsarev, PostgresPro

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message m.litsarev 2026-06-11 15:09:56 Re: Fix warning: ‘startpos’ may be used uninitialized in function ‘results_differ’
Previous Message Mark Wong 2026-06-11 14:47:37 Re: updates for handling optional argument in system functions