pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Paquier <michael@paquier.xyz>
To: Andrey Lepikhov <a.lepikhov@postgrespro.ru>
Cc: PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>
Subject: Re: Warning in the RecordTransactionAbort routine during compilation with O3 flag
Date: Tue, 10 Dec 2019 12:13:28 +0900
Message-ID: <20191210031328.GG72921@paquier.xyz> (raw)
In-Reply-To: <287cdd37-4021-da81-0378-cd367a279577@postgrespro.ru>
References: <a7e28b83-27b1-4e1c-c76b-4268c4b785bc@postgrespro.ru>
	<20191209080316.GA72921@paquier.xyz>
	<287cdd37-4021-da81-0378-cd367a279577@postgrespro.ru>

On Mon, Dec 09, 2019 at 02:03:43PM +0500, Andrey Lepikhov wrote:
> We already have assertion on the twophase_gid variable. But compiler is not
> so smart and can't find a link between the XACT_XINFO_HAS_GID flag and
> state of twophase_gid pointer.

Well, gcc-9 got visibly smarter on that point :)

> Ok. In accordance with your review, I have prepared a new version of the
> patch.

Regarding formatting.c, I can see the point of avoiding future
mistakes, and I would go a bit further as per the attached for
consistency between all variables.  have_error is a bit trickier
though as it gets moved around more layers so doing an initialization
in the middle is not really an option.  Anyway, we can do that rather
cleanly from the entry point of do_to_timestamp() to bring more
consistency for variables which are always expected and the optional
ones.  What do you think?

For the second one in xact.c, I am not really on board of doing
something based on the proposals because this reduces the code
visibility, and gcc is clearly wrong in its assumptions because the
state cannot be reached.

> My compiler:
> 
> gcc -v
> [...]
> gcc version 7.4.0 (Ubuntu 7.4.0-1ubuntu1~18.04.1)

Thanks, that's the difference.  gcc-9 does not complain, but I can see
the warnings with gcc-7 (7.5.0 actually).
--
xMichael

Attachments:

tmsp-formatting-warnings.patch (text/x-diff, 866B) download diff --git a/src/backend/utils/adt/formatting.c b/src/backend/utils/adt/formatting.c index f7175df8da..8fcbc2267f 100644 --- a/src/backend/utils/adt/formatting.c +++ b/src/backend/utils/adt/formatting.c @@ -4128,7 +4128,7 @@ parse_datetime(text *date_txt, text *fmt, bool strict, Oid *typid, { struct pg_tm tm; fsec_t fsec; - int fprec = 0; + int fprec; uint32 flags; do_to_timestamp(date_txt, fmt, strict, &tm, &fsec, &fprec, &flags, have_error); @@ -4318,11 +4318,18 @@ do_to_timestamp(text *date_txt, text *fmt, bool std, int fmask; bool incache = false; + Assert(tm != NULL); + Assert(fsec != NULL); + date_str = text_to_cstring(date_txt); ZERO_tmfc(&tmfc); ZERO_tm(tm); *fsec = 0; + if (fprec) + *fprec = 0; + if (flags) + *flags = 0; fmask = 0; /* bit mask for ValidateDate() */ fmt_len = VARSIZE_ANY_EXHDR(fmt);
signature.asc (application/pgp-signature, 832B) download

view thread (6+ messages)  latest in thread

Message-ID: <20191210031328.GG72921@paquier.xyz>
Permalink:  ../20191210031328.GG72921@paquier.xyz/
Also on:    postgresql.org/message-id/20191210031328.GG72921@paquier.xyz

 ·  · 

reply

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: michael@paquier.xyz, a.lepikhov@postgrespro.ru
  Subject: Re: Warning in the RecordTransactionAbort routine during compilation with O3 flag
  In-Reply-To: <20191210031328.GG72921@paquier.xyz>
  References: <a7e28b83-27b1-4e1c-c76b-4268c4b785bc@postgrespro.ru> <20191209080316.GA72921@paquier.xyz> <287cdd37-4021-da81-0378-cd367a279577@postgrespro.ru> <20191210031328.GG72921@paquier.xyz>

* 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