Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wI90F-007pPZ-0G for pgsql-hackers@arkaria.postgresql.org; Wed, 29 Apr 2026 17:47:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wI90E-004YwO-0U for pgsql-hackers@arkaria.postgresql.org; Wed, 29 Apr 2026 17:47:14 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wI90D-004YwG-13 for pgsql-hackers@lists.postgresql.org; Wed, 29 Apr 2026 17:47:13 +0000 Received: from fout-a2-smtp.messagingengine.com ([103.168.172.145]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wI90A-00000003NfN-3f55 for pgsql-hackers@postgresql.org; Wed, 29 Apr 2026 17:47:12 +0000 Received: from phl-compute-05.internal (phl-compute-05.internal [10.202.2.45]) by mailfout.phl.internal (Postfix) with ESMTP id E47F8EC00A3 for ; Wed, 29 Apr 2026 13:47:09 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-05.internal (MEProxy); Wed, 29 Apr 2026 13:47:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.de; h= cc:content-transfer-encoding:content-type:content-type:date:date :from:from:in-reply-to:message-id:mime-version:reply-to:subject :subject:to:to; s=fm2; t=1777484829; x=1777571229; bh=aOJcq2J5xr EEZpQLgCTE9+yIvyXsNDkiA8UuK3R+P98=; b=rhmvxG+x9fo6P9c4A1VcXHKty7 vwdntRqsJwozLNs6EvHdt2xd6nwAEJGueQDIAgfnJis64fFDBBrDNlHoNlpfXAAL xV9vQMi2+X9t67q5jQChVHz6XziSATwXZwTSKjPvLJHw8xLCvnJrfDYuVoKpXHN4 w92kvhmKEJhxkmVxjpnJusUBtrAN45N4M3j5YPufYk/SPYOFYIA0SMHV0fvV6XN5 MOitLoP3TyESWJK1i7M68lXmdwXfbxp4E1L87D0q8KnmNshgC+QaEEbqnfJYhWXi zHKAP9RKvWmD1rn8eUH9UNnDXSVz/fDfMvlCFb3dmED8ow3LB+B/ANu3ybeA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:message-id:mime-version:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t= 1777484829; x=1777571229; bh=aOJcq2J5xrEEZpQLgCTE9+yIvyXsNDkiA8U uK3R+P98=; b=TnIVCHM/TDkbgC1mdbI5Wu7d5n1nCFtxqFlD9xwTeB1k/07bG05 JzXXFhj3mMsY4Ln9+isKmWUjDg8Llhf9+oB+3wpdNkVUiHNttywb2GJmQNxHN0/q aZrfrOGitpPqha8krLiWf6mMuRhDbKF2U2wL0c+G2kP/zmRGo8/708ZQ0OIDM50X Wl8xgWoN3TqSUjTi7fJzo1kUktlEfHDfi/YZxb5GdDcCdd7K4IV4VOrlNBo5/3Ww 6lvoMhRjHTKp/2J45YbgiOCspndxB7d/NAsXNMugV4ZFpllTRTZRQgMifrZlPDD3 J7DnNbt8Z1LCTvGrDIges8hqwEzbxWoJigg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefhedrtddtgdekhedtkecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecunecujfgurhepfffhvffukfggtggugfestheksfdttddtje enucfhrhhomheptehnughrvghsucfhrhgvuhhnugcuoegrnhgurhgvshesrghnrghrrgii vghlrdguvgeqnecuggftrfgrthhtvghrnhepudffgeeftdehtdejfeeuvdeufeefgeehfe ekiedvgfdvteevudeuveffteetgefhnecuffhomhgrihhnpehgnhhurdhorhhgnecuvehl uhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprghnughrvghsse grnhgrrhgriigvlhdruggvpdhnsggprhgtphhtthhopedupdhmohguvgepshhmthhpohhu thdprhgtphhtthhopehpghhsqhhlqdhhrggtkhgvrhhssehpohhsthhgrhgvshhqlhdroh hrgh X-ME-Proxy: Feedback-ID: id4a34324:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Wed, 29 Apr 2026 13:47:09 -0400 (EDT) Date: Wed, 29 Apr 2026 13:47:08 -0400 From: Andres Freund To: pgsql-hackers@postgresql.org Subject: Spurious warnings in crypto-des.c when building with gcc-16 -O3 Message-ID: <3nuudxv365kjnmwjhnygdakhxuktpdjvf26rt26eb44esgqdrj@y2x3vomkrfoo> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, Recently I got a bit of a shock building postgres with gcc-16: ../../../../../home/andres/src/postgresql/contrib/pgcrypto/crypt-des.c: In function ‘px_crypt_des’: ../../../../../home/andres/src/postgresql/contrib/pgcrypto/crypt-des.c:675:22: warning: writing 8 bytes into a region of size 7 [-Wstringop-overflow=] 675 | *q++ = *key << 1; | ~~~~~^~~~~~~~~~~ ../../../../../home/andres/src/postgresql/contrib/pgcrypto/crypt-des.c:659:33: note: at offset [1, 2] into destination object ‘keybuf’ of size 8 659 | keybuf[2]; | ^~~~~~ ../../../../../home/andres/src/postgresql/contrib/pgcrypto/crypt-des.c:659:33: note: at offset [2, 3] into destination object ‘keybuf’ of size 8 ../../../../../home/andres/src/postgresql/contrib/pgcrypto/crypt-des.c:659:33: note: at offset [3, 4] into destination object ‘keybuf’ of size 8 ../../../../../home/andres/src/postgresql/contrib/pgcrypto/crypt-des.c:659:33: note: at offset [4, 5] into destination object ‘keybuf’ of size 8 ../../../../../home/andres/src/postgresql/contrib/pgcrypto/crypt-des.c:659:33: note: at offset [5, 6] into destination object ‘keybuf’ of size 8 ../../../../../home/andres/src/postgresql/contrib/pgcrypto/crypt-des.c:659:33: note: at offset [6, 7] into destination object ‘keybuf’ of size 8 ../../../../../home/andres/src/postgresql/contrib/pgcrypto/crypt-des.c:659:33: note: at offset [7, 8] into destination object ‘keybuf’ of size 8 ../../../../../home/andres/src/postgresql/contrib/pgcrypto/crypt-des.c:675:22: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=] 675 | *q++ = *key << 1; | ~~~~~^~~~~~~~~~~ ../../../../../home/andres/src/postgresql/contrib/pgcrypto/crypt-des.c:659:33: note: at offset 8 into destination object ‘keybuf’ of size 8 659 | keybuf[2]; | ^~~~~~ ../../../../../home/andres/src/postgresql/contrib/pgcrypto/crypt-des.c:659:33: note: at offset [9, 10] into destination object ‘keybuf’ of size 8 ../../../../../home/andres/src/postgresql/contrib/pgcrypto/crypt-des.c:659:33: note: at offset [10, 11] into destination object ‘keybuf’ of size 8 ../../../../../home/andres/src/postgresql/contrib/pgcrypto/crypt-des.c:659:33: note: at offset [11, 12] into destination object ‘keybuf’ of size 8 ../../../../../home/andres/src/postgresql/contrib/pgcrypto/crypt-des.c:659:33: note: at offset [12, 13] into destination object ‘keybuf’ of size 8 ../../../../../home/andres/src/postgresql/contrib/pgcrypto/crypt-des.c:659:33: note: at offset [13, 14] into destination object ‘keybuf’ of size 8 ../../../../../home/andres/src/postgresql/contrib/pgcrypto/crypt-des.c:659:33: note: at offset [14, 15] into destination object ‘keybuf’ of size 8 Luckily it turns out that that the warning is spurious, due to a bug in gcc [1]. However, it took me quite a while to figure out what the hell the code was doing: char * px_crypt_des(const char *key, const char *setting) { uint32 keybuf[2]; ... uint8 *q; ... /* * Copy the key, shifting each character up by one bit and padding with * zeros. */ q = (uint8 *) keybuf; while (q - (uint8 *) keybuf - 8) { *q++ = *key << 1; if (*key != '\0') key++; } Like, it's far from immediately obvious where the 8 is coming from (it's the size of keybuf), whether there are precedence issues or what this is even trying to achieve. And it's still not clear to me why on earth it makes sense to write it that complicated, when it seems something like for (int byteno = 0; byteno < sizeof(keybuf); byteno++) { *q++ = *key << 1; if (*key != '\0') key++; } would do the same thing, except be trivially understandable for humans and compilers. Am I missing something or is what I suggest equivalent? Any reason to not change it that way, both to clarify the code and to work around the spurious warning? Greetings, Andres Freund [1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113664