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 1ieExM-0000Xs-Dk for pgsql-bugs@arkaria.postgresql.org; Mon, 09 Dec 2019 09:03:53 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1ieExL-00089D-6T for pgsql-bugs@arkaria.postgresql.org; Mon, 09 Dec 2019 09:03:51 +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 1ieExK-000894-OO for pgsql-bugs@lists.postgresql.org; Mon, 09 Dec 2019 09:03:50 +0000 Received: from cyclops.postgrespro.ru ([93.174.131.138] helo=mail.postgrespro.ru) by magus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1ieExH-0000yA-Gj for pgsql-bugs@lists.postgresql.org; Mon, 09 Dec 2019 09:03:50 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.postgrespro.ru (Postfix) with ESMTP id A3EAC21C3C1E; Mon, 9 Dec 2019 12:03:45 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at postgrespro.ru X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=x tagged_above=-99 required=4 WHITELISTED tests=[] autolearn=unavailable Received: from [192.168.129.217] (unknown [94.25.177.187]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mail.postgrespro.ru (Postfix) with ESMTPSA id 1D00A21C2824; Mon, 9 Dec 2019 12:03:44 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1575882225; bh=FfzlslMO0kPHB5KMn8uCWgOUBMZYrGqdQ0xqmIvBAzg=; h=Subject:To:Cc:References:From:Date:In-Reply-To; b=eZqN/3IEYZajB585WjVlghPR19xhnRLYKg54zzCan5IBO91MjIsYyCKrc6uAsgAbD vvIFvQULAFnCYc3bZE7LeREL34fjEkS7hlygmOdDO7CBjLWxLdJxwPgZEi8Hwdy6v7 k6MmeSb7C25NtTujaqeA309I6RexJVlW+P05QmIA= Subject: Re: Warning in the RecordTransactionAbort routine during compilation with O3 flag To: Michael Paquier Cc: PostgreSQL mailing lists References: <20191209080316.GA72921@paquier.xyz> From: Andrey Lepikhov Organization: Postgres Professional Message-ID: <287cdd37-4021-da81-0378-cd367a279577@postgrespro.ru> Date: Mon, 9 Dec 2019 14:03:43 +0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.1 MIME-Version: 1.0 In-Reply-To: <20191209080316.GA72921@paquier.xyz> Content-Type: multipart/mixed; boundary="------------8650397D20311F8A79505082" Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------8650397D20311F8A79505082 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit 09.12.2019 13:03, Michael Paquier пишет: > On Mon, Dec 09, 2019 at 08:49:26AM +0500, Andrey Lepikhov wrote: >> xact.c: In function ‘RecordTransactionAbort’: >> xact.c:5709:55: warning: argument 1 null where non-null expected [-Wnonnull] >> XLogRegisterData(unconstify(char *, twophase_gid), strlen(twophase_gid) >> + 1); > > Assert(twophase_gid != NULL); > - > - if (XLogLogicalInfoActive()) > - xl_xinfo.xinfo |= XACT_XINFO_HAS_GID; > > xlinfo is set in the first part logging the transaction commit and the > record data is registered in the second, so I think that the original > coding makes more sense than what you are suggesting. Perhaps it > would help to just add an assertion on twophase_gid to make sure that > it is not NULL in the part registering the data? After that we really > have no bugs here, so it does not really help much.. 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. > >> formatting.c: In function ‘parse_datetime’: >> formatting.c:4229:13: warning: ‘flags’ may be used uninitialized in this >> function [-Wmaybe-uninitialized] >> if (flags & DCH_ZONED) > > - uint32 flags; > + uint32 flags = 0; > > do_to_timestamp(date_txt, fmt, strict, &tm, &fsec, &fprec, &flags, have_error); > > For this one, OK. Wouldn't it be better to initialize flags, fprec > and have_error directly in do_to_timestamp if they are not NULL? This > way future callers of the routine, if any, won't miss the > initialization. Ok. In accordance with your review, I have prepared a new version of the patch. > > By the way, are you using more specific CFLAGS to see that? With -O3 > and -Wnonnull I cannot spot both issues with GCC 9.2.1. My compilation procedure: export CFLAGS="-O3" ./configure --prefix=`pwd`/tmp_install --enable-tap-tests --enable-depend && make clean make > /dev/null make install > /dev/null My compiler: gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/7/lto-wrapper OFFLOAD_TARGET_NAMES=nvptx-none OFFLOAD_TARGET_DEFAULT=1 Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Ubuntu 7.4.0-1ubuntu1~18.04.1' --with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-7 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu Thread model: posix gcc version 7.4.0 (Ubuntu 7.4.0-1ubuntu1~18.04.1) -- Andrey Lepikhov Postgres Professional https://postgrespro.com The Russian Postgres Company --------------8650397D20311F8A79505082 Content-Type: text/x-patch; charset=UTF-8; name="v2-0001-Make-compiler-quiet.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="v2-0001-Make-compiler-quiet.patch"