From: Tristan Partin <tristan@neon.tech>
To: Peter Eisentraut <peter@eisentraut.org>
Cc: pgsql-hackers@postgresql.org
Subject: Re: Fix last unitialized memory warning
Date: Wed, 09 Aug 2023 10:29:56 -0500
Message-ID: <CUO4DOBLGCGQ.2O00AZU0E82UY@gonk> (raw)
In-Reply-To: <7ae6b2ac-b7e4-8a19-9421-2c6e7add0188@eisentraut.org>
References: <CT6HJ3U8068R.3A8SJMV02D9BC@gonk>
<8f7880cc-3622-1c0a-a126-5b47aafeee51@eisentraut.org>
<CTUJMJ1B57SL.3T8TKNTE9XSVD@gonk>
<fe3d9d88-9702-3339-d86a-98a121244c9c@eisentraut.org>
<CTV4SEUNM92R.2OM4SN8LB7CQN@gonk>
<54989bdd-d6fe-92dc-a7e3-f4f31252b7eb@eisentraut.org>
<CU6BH3JA3GCY.25ETDNK3LVULF@gonk>
<c1d63155-7ac7-90dc-2e82-12b97e497026@eisentraut.org>
<CUN9FLTQAMIQ.RANXYVABYETV@gonk>
<a88b0adf-9e26-fbbc-805e-6e0da5ae64bf@eisentraut.org>
<7ae6b2ac-b7e4-8a19-9421-2c6e7add0188@eisentraut.org>
On Wed Aug 9, 2023 at 10:02 AM CDT, Peter Eisentraut wrote:
> On 09.08.23 10:07, Peter Eisentraut wrote:
> > On 08.08.23 17:14, Tristan Partin wrote:
> >>> I was able to reproduce the warning now on Fedora. I agree with the
> >>> patch
> >>>
> >>> - PgBenchValue vargs[MAX_FARGS];
> >>> + PgBenchValue vargs[MAX_FARGS] = { 0 };
> >>>
> >>> I suggest to also do
> >>>
> >>> typedef enum
> >>> {
> >>> - PGBT_NO_VALUE,
> >>> + PGBT_NO_VALUE = 0,
> >>>
> >>> to make clear that the initialization value is meant to be invalid.
> >>>
> >>> I also got the plpgsql warning that you showed earlier, but I
> >>> couldn't think of a reasonable way to fix that.
> >>
> >> Applied in v2.
> >
> > committed
>
> This patch has apparently upset one buildfarm member with a very old
> compiler:
> https://buildfarm.postgresql.org/cgi-bin/show_history.pl?nm=lapwing&br=HEAD
>
> Any thoughts?
Best I could find is SO question[0] which links out to[1]. Try this
patch. Otherwise, a memset() would probably do too.
[0]: https://stackoverflow.com/questions/13746033/how-to-repair-warning-missing-braces-around-initializer
[1]: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53119
--
Tristan Partin
Neon (https://neon.tech)
Attachments:v1-0001-Fix-erroneous-Werror-missing-braces-on-old-GCC.patch (text/x-patch, 1.2K) download
From ecb342a88e5fb2a88f0086dcf46fdcadb6d930ba Mon Sep 17 00:00:00 2001
From: Tristan Partin <tristan@neon.tech>
Date: Wed, 9 Aug 2023 10:12:47 -0500
Subject: [PATCH v1] Fix erroneous -Werror=missing-braces on old GCC
The buildfarm reports that this is an error on gcc (Debian 4.7.2-5)
4.7.2, 32-bit. The bug seems to be GCC bug 53119, which has obviously
been fixed for years.
---
src/bin/pgbench/pgbench.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/bin/pgbench/pgbench.c b/src/bin/pgbench/pgbench.cindex 2ba3e367c4..d2b7fc87e4 100644--- a/src/bin/pgbench/pgbench.c+++ b/src/bin/pgbench/pgbench.c@@ -2239,10 +2239,15 @@ evalStandardFunc(CState *st,
{
/* evaluate all function arguments */
int nargs = 0;
- PgBenchValue vargs[MAX_FARGS] = { 0 };
PgBenchExprLink *l = args;
bool has_null = false;
+ /*+ * This value is double braced to workaround GCC bug 53119, which seems to+ * exist at least on gcc (Debian 4.7.2-5) 4.7.2, 32-bit.+ */+ PgBenchValue vargs[MAX_FARGS] = { { 0 } };+
for (nargs = 0; nargs < MAX_FARGS && l != NULL; nargs++, l = l->next)
{
if (!evaluateExpr(st, l->expr, &vargs[nargs]))
--
Tristan Partin
Neon (https://neon.tech)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: tristan@neon.tech, peter@eisentraut.org
Subject: Re: Fix last unitialized memory warning
In-Reply-To: <CUO4DOBLGCGQ.2O00AZU0E82UY@gonk>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox