Re: silence GCC4 warning - Mailing list pgsql-patches

From Neil Conway
Subject Re: silence GCC4 warning
Date
Msg-id 42C9D1B0.6050000@samurai.com
Whole thread Raw
In response to Re: silence GCC4 warning  (Peter Eisentraut <peter_e@gmx.net>)
Responses Re: silence GCC4 warning  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-patches
Peter Eisentraut wrote:
> A simple test shows that this is not the case, even with lots of -W
> options.

Right -- AFAICS we only get the following warnings of this class with
GCC 4.0 on current sources:

% gcc --version
gcc-4.0 (GCC) 4.0.1 20050701 (prerelease) (Debian 4.0.0-12)
[...]
% make -s clean all
[...]
In file included from /home/neilc/pgsql/src/backend/regex/regexec.c:1070:
/home/neilc/pgsql/src/backend/regex/rege_dfa.c: In function 'getvacant':
/home/neilc/pgsql/src/backend/regex/rege_dfa.c:581: warning: 'lastap.ss'
may be used uninitialized in this function
/home/neilc/pgsql/src/backend/regex/rege_dfa.c:581: warning: 'lastap.co'
may be used uninitialized in this function

/home/neilc/pgsql/src/backend/utils/adt/inet_net_ntop.c: In function
'inet_net_ntop_ipv6':
/home/neilc/pgsql/src/backend/utils/adt/inet_net_ntop.c:427: warning:
'cur.len' may be used uninitialized in this function
/home/neilc/pgsql/src/backend/utils/adt/inet_net_ntop.c:427: warning:
'best.len' may be used uninitialized in this function

/home/neilc/pgsql/src/interfaces/ecpg/pgtypeslib/datetime.c: In function
'PGTYPESdate_defmt_asc':
/home/neilc/pgsql/src/interfaces/ecpg/pgtypeslib/datetime.c:335:
warning: 'tm.tm_mday' may be used uninitialized in this function
/home/neilc/pgsql/src/interfaces/ecpg/pgtypeslib/datetime.c:335:
warning: 'tm.tm_mon' may be used uninitialized in this function
/home/neilc/pgsql/src/interfaces/ecpg/pgtypeslib/datetime.c:335:
warning: 'tm.tm_year' may be used uninitialized in this function

/home/neilc/pgsql/src/pl/plpgsql/src/pl_comp.c: In function
'plpgsql_parse_tripwordtype':
/home/neilc/pgsql/src/pl/plpgsql/src/pl_comp.c:1372: warning: 'cp[0]'
may be used uninitialized in this function
/home/neilc/pgsql/src/pl/plpgsql/src/pl_comp.c:1372: warning: 'cp[1]'
may be used uninitialized in this function

(Plus many errors regarding signedness, which is a separate matter.)

All these warnings like somewhat reasonable, AFAICS: while the code may
actually always initialize the variables before using them, it's
understandable that the compiler can't infer this automatically. And
this is surely a tiny fraction of the changes that would be required if
something as fundamental as initialization via out parameters was broken.

-Neil

pgsql-patches by date:

Previous
From: Victor Yegorov
Date:
Subject: Re: Bitmap index AM
Next
From: Neil Conway
Date:
Subject: Re: [HACKERS] [PATCH] pgcrypto: pgp_encrypt v3