Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ieVy1-0007eC-M8 for pgsql-bugs@arkaria.postgresql.org; Tue, 10 Dec 2019 03:13:42 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1ieVxz-0007SV-7l for pgsql-bugs@arkaria.postgresql.org; Tue, 10 Dec 2019 03:13:39 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ieVxx-0007S9-VP for pgsql-bugs@lists.postgresql.org; Tue, 10 Dec 2019 03:13:39 +0000 Received: from out3-smtp.messagingengine.com ([66.111.4.27]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ieVxv-0001kd-Ew for pgsql-bugs@lists.postgresql.org; Tue, 10 Dec 2019 03:13:37 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 5AF8F22513; Mon, 9 Dec 2019 22:13:33 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Mon, 09 Dec 2019 22:13:33 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm3; bh=l80PR9csqNwDyqbxlUNG9mdZUiS xgzSfB/Rc65L+0IQ=; b=fWRd50LnfhuJYnhmmrSZb8SEGhpYH20gR3LzZfOXYpV 9Z8pwLWd+N4HonQ6Wq3QEQHmH68LIZdcyuLD+rfhG1NMPja/PhSWU6XCQo/qzWtD RwL3tdv4TBlDFZu9g8+Wy7dsj43jHzZt42fMSqDEwcST7vOlaiE5Nxm3UpthDkAf s/940jA5WYIiGV5nOf80IL4KxZ9Jkl7WVoqmbfU+LTsdDjVD4zBJr73eJDJEcNB7 I6oyHewFdM9T11fW2W6eLXb8bVTJ4ut8ZdTZEOObAMAagJ5Ys1r0XcGvfjPa5kmO TVbDlYRSZnlnNzaJGKOfGFqnkSlEnlpT/0VTyAPpHEg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=l80PR9 csqNwDyqbxlUNG9mdZUiSxgzSfB/Rc65L+0IQ=; b=Z/Q0Kh9+FQzwp9OLPIZC8P WUuPS5bURnL2LxV27joYwH0WGVrvQtY0PR6UL7ChD+NopCVEVnS3gWJHxTcBvp/X BN5NmY3aMBH582xACMoRmfgJi2Sh+tLYQM2uBnluWpx97d7AUaKOVjvTajZoMVZN yv591WHTuZt8cgLabZ3Za0SUzChb31hZhu3DyMkXooOQdVFUYz61DN4P1UHcdUM/ gA6GWmDcgpeWtd0aa8jTkq2fLi0G/pbCQRbW5Lj0rhG5b6CztpcbqtqHoOkgeJ/2 X12z+hnfT6iU5DpxwX+LFn7gXCBY8VGli4owRKT+i+qybuhubrpqm7lztGznyKtw == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedufedrudelvddghedvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne gfrhhlucfvnfffucdljedtmdenucfjughrpeffhffvuffkfhggtggujgesghdtreertddt vdenucfhrhhomhepofhitghhrggvlhcurfgrqhhuihgvrhcuoehmihgthhgrvghlsehprg hquhhivghrrdighiiiqeenucfkphepudduuddruddtvddrudektddrudekheenucfrrghr rghmpehmrghilhhfrhhomhepmhhitghhrggvlhesphgrqhhuihgvrhdrgiihiienucevlh hushhtvghrufhiiigvpedt X-ME-Proxy: Received: from paquier.xyz (ee0822lan1.rev.em-net.ne.jp [111.102.180.185]) by mail.messagingengine.com (Postfix) with ESMTPA id 9ACAB8005A; Mon, 9 Dec 2019 22:13:31 -0500 (EST) Date: Tue, 10 Dec 2019 12:13:28 +0900 From: Michael Paquier To: Andrey Lepikhov Cc: PostgreSQL mailing lists Subject: Re: Warning in the RecordTransactionAbort routine during compilation with O3 flag Message-ID: <20191210031328.GG72921@paquier.xyz> References: <20191209080316.GA72921@paquier.xyz> <287cdd37-4021-da81-0378-cd367a279577@postgrespro.ru> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="MPkR1dXiUZqK+927" Content-Disposition: inline In-Reply-To: <287cdd37-4021-da81-0378-cd367a279577@postgrespro.ru> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --MPkR1dXiUZqK+927 Content-Type: multipart/mixed; boundary="h3LYUU6HlUDSAOzy" Content-Disposition: inline --h3LYUU6HlUDSAOzy Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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 n= ot > 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: >=20 > 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 --h3LYUU6HlUDSAOzy Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="tmsp-formatting-warnings.patch" Content-Transfer-Encoding: quoted-printable diff --git a/src/backend/utils/adt/formatting.c b/src/backend/utils/adt/for= matting.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 =3D 0; + int fprec; uint32 flags; =20 do_to_timestamp(date_txt, fmt, strict, &tm, &fsec, &fprec, &flags, have_e= rror); @@ -4318,11 +4318,18 @@ do_to_timestamp(text *date_txt, text *fmt, bool std, int fmask; bool incache =3D false; =20 + Assert(tm !=3D NULL); + Assert(fsec !=3D NULL); + date_str =3D text_to_cstring(date_txt); =20 ZERO_tmfc(&tmfc); ZERO_tm(tm); *fsec =3D 0; + if (fprec) + *fprec =3D 0; + if (flags) + *flags =3D 0; fmask =3D 0; /* bit mask for ValidateDate() */ =20 fmt_len =3D VARSIZE_ANY_EXHDR(fmt); --h3LYUU6HlUDSAOzy-- --MPkR1dXiUZqK+927 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAl3vDVgACgkQnvQgOdby QH39nA//dMFgDFG6G/e5DBoooAOJu8n3J/vS93AgOtlEPJweKtA61KrWhCw8kMR3 Vfhao0pKHE7d/sVHmReomXKR2U5HnVTXRN6eFzBmD7KptJoO46+Nf+wd9gGDtL7b fhgZY+vO7mlca5ccZZaDHpW0tbJ7IBPrbGenhxqTL6kt40lB47tq1ljNQoB/fyFn nuLFAnac3lLp7qabicNYMBRClTMqsBYwQJmR3L8Gmkh6fem9fWbz/wt2r8qcUzSL mGu2a79JH7g9z6MzhBfmYLiMlo7vE7SsOnkraUSvidWwHg4kbp0DghnSPboODVzD VkIbFfSEpLPTj1JzTMh9nL/kxyKRR0HzkSSucWqf1GsusJexUiyPSuIFvVdZUHzs d8tAb3kboN4YoYNDL0VliIf6ea6McxCewhz0LrEXVBwl3KE4XcgaBDcmQlrCYNYZ zPJbJ12wkh4dl42tAnPi/JIlSrVofZ3JqTi3gLyjbiuxb/grnGfrcWPp9kAgQwvS b7PTxkGVPoREtd5sgeE+gjOIOrQ4r61g5UUzNGMOaExK0sOlOtxm38PvdRDBmI4Z LeNbANzJXjm1oq7p0rOK6AOTTnUWwlooNfA50yhpNMDdgSh1q9UFMXNAAmp4h1R9 JIvXaspR3s8kEr/xVcUDWemX0oPrU6mSDV+gCRW9J4/Y8jAIHlw= =PZfq -----END PGP SIGNATURE----- --MPkR1dXiUZqK+927--