Thread: Fw: [COMMITTERS] pgsql: Fix blatantly broken record_image_cmp() logic for pass-by-value
Fw: [COMMITTERS] pgsql: Fix blatantly broken record_image_cmp() logic for pass-by-value
From
Kevin Grittner
Date:
Forwarded to -hackers ----- Forwarded Message ----- > From: Kevin Grittner <kgrittn@ymail.com> > To: Kevin Grittner <kgrittn@ymail.com>; Tom Lane <tgl@sss.pgh.pa.us> > Cc: "pgsql-committers@postgresql.org" <pgsql-committers@postgresql.org> > Sent: Friday, November 8, 2013 4:33 PM > Subject: Re: [COMMITTERS] pgsql: Fix blatantly broken record_image_cmp() logic for pass-by-value > > Kevin Grittner <kgrittn@ymail.com> wrote: > >> I distilled it down to the simplest case I could find which >> failed to produce the warning; attached. > > For a compiler which seems to like to generate warnings for really > esoteric cases, clang falls down rather badly on uninitialized > variables -- at least on the package for Ubuntu 12.10. It does not > complain at all about this: > > > int warning_test(int a); > int warning_test(int a) > { > int result; > > if (a == 1) > result = 1; > > return result; > } > > > I assume that everyone here agrees that merits a warning? > > Bug reports filed. > > > -- > Kevin Grittner > EDB: http://www.enterprisedb.com > The Enterprise PostgreSQL Company >
Re: Fw: [COMMITTERS] pgsql: Fix blatantly broken record_image_cmp() logic for pass-by-value
From
Kevin Grittner
Date:
Kevin Grittner <kgrittn@ymail.com> wrote: >> int warning_test(int a); >> int warning_test(int a) >> { >> int result; >> >> if (a == 1) >> result = 1; >> >> return result; >> } I had to file separate bug reports for gcc and clang. I have already gotten a response on the clang bug report using the above test code. It was closed with this response: Fixed from clang 3.3 warning_test.c:8:6: warning: variable 'result' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized] if (a == 1) ^~~~~~ warning_test.c:11:9: note: uninitialized use occurs here return result; ^~~~~~ warning_test.c:8:2: note: remove the 'if' if its condition is always true if (a == 1) ^~~~~~~~~~~ warning_test.c:6:14: note: initialize the variable 'result' to silence this warning int result; ^ = 0 ** Changed in: clang (Ubuntu) Status: New => Fix Released I take that to say that the bug will be fixed in clang version 3.3, which is not available in any production release of Ubuntu. -- Kevin Grittner EDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company