Re: silence GCC4 warning

From: Neil Conway <neilc(at)samurai(dot)com>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: silence GCC4 warning
Date: 2005-07-05 00:17:52
Message-ID: 42C9D1B0.6050000@samurai.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Neil Conway 2005-07-05 00:20:17 Re: [HACKERS] [PATCH] pgcrypto: pgp_encrypt v3
Previous Message Victor Yegorov 2005-07-04 23:15:03 Re: Bitmap index AM