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

m.litsarev@postgrespro.ru

From: m.litsarev@postgrespro.ru
To: pgsql-hackers@lists.postgresql.org
Date: 2026-06-11T15:08:13Z
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



Commits

  1. Silence uninitialized variable warning with some compiler versions

  2. pg_regress: Include diffs in TAP output