Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kQohV-0004Jw-H9 for pgsql-hackers@arkaria.postgresql.org; Fri, 09 Oct 2020 09:28:33 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kQohU-000811-ES for pgsql-hackers@arkaria.postgresql.org; Fri, 09 Oct 2020 09:28:32 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kQohU-00080g-7L for pgsql-hackers@lists.postgresql.org; Fri, 09 Oct 2020 09:28:32 +0000 Received: from feynman.df7cb.de ([195.49.152.168]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kQohQ-0007Vv-Kj for pgsql-hackers@lists.postgresql.org; Fri, 09 Oct 2020 09:28:31 +0000 Received: from msg.df7cb.de (unknown [IPv6:2003:5b:203b:100:7627:eaff:fe52:8e03]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by feynman.df7cb.de (Postfix) with ESMTPSA id 4C72n53tnDz3Dwv; Fri, 9 Oct 2020 11:28:25 +0200 (CEST) Date: Fri, 9 Oct 2020 11:28:25 +0200 From: Christoph Berg To: Noah Misch Cc: pgsql-hackers@lists.postgresql.org Subject: powerpc pg_atomic_compare_exchange_u32_impl: error: comparison of integer expressions of different signedness (Re: pgsql: For all ppc compilers, implement compare_exchange and) fetch_add Message-ID: <20201009092825.GD889580@msg.df7cb.de> References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Re: Noah Misch > For all ppc compilers, implement compare_exchange and fetch_add with asm. > > This is more like how we handle s_lock.h and arch-x86.h. > > Reviewed by Tom Lane. > > Discussion: https://postgr.es/m/20191005173400.GA3979129@rfd.leadboat.com Hi, pg-cron on powerpc/ppc64/ppc64el is raising this warning inside the ppc atomics: gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough=3 -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Wno-format-truncation -Wno-stringop-truncation -g -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -g -O2 -fdebug-prefix-map=/<>=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -std=c99 -Wall -Wextra -Werror -Wno-unknown-warning-option -Wno-unused-parameter -Wno-maybe-uninitialized -Wno-implicit-fallthrough -Iinclude -I/usr/include/postgresql -I. -I./ -I/usr/include/postgresql/13/server -I/usr/include/postgresql/internal -Wdate-time -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -I/usr/include/libxml2 -c -o src/job_metadata.o src/job_metadata.c In file included from /usr/include/postgresql/13/server/port/atomics.h:74, from /usr/include/postgresql/13/server/utils/dsa.h:17, from /usr/include/postgresql/13/server/nodes/tidbitmap.h:26, from /usr/include/postgresql/13/server/access/genam.h:19, from src/job_metadata.c:21: /usr/include/postgresql/13/server/port/atomics/arch-ppc.h: In function ‘pg_atomic_compare_exchange_u32_impl’: /usr/include/postgresql/13/server/port/atomics/arch-ppc.h:97:42: error: comparison of integer expressions of different signedness: ‘uint32’ {aka ‘unsigned int’} and ‘int’ [-Werror=sign-compare] 97 | *expected <= PG_INT16_MAX && *expected >= PG_INT16_MIN) | ^~ src/job_metadata.c: At top level: cc1: note: unrecognized command-line option ‘-Wno-unknown-warning-option’ may have been intended to silence earlier diagnostics cc1: all warnings being treated as errors Looking at the pg_atomic_compare_exchange_u32_impl, this looks like a genuine problem: static inline bool pg_atomic_compare_exchange_u32_impl(volatile pg_atomic_uint32 *ptr, uint32 *expected, uint32 newval) ... if (__builtin_constant_p(*expected) && *expected <= PG_INT16_MAX && *expected >= PG_INT16_MIN) If *expected is an unsigned integer, comparing it to PG_INT16_MIN which is a negative number doesn't make sense. src/include/c.h:#define PG_INT16_MIN (-0x7FFF-1) Christoph