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 1wA7TB-00250W-2Q for pgsql-hackers@arkaria.postgresql.org; Tue, 07 Apr 2026 14:31:57 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wA7TA-000hy1-0j for pgsql-hackers@arkaria.postgresql.org; Tue, 07 Apr 2026 14:31:56 +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 1wA7T9-000hxs-0t for pgsql-hackers@lists.postgresql.org; Tue, 07 Apr 2026 14:31:56 +0000 Received: from fout-b8-smtp.messagingengine.com ([202.12.124.151]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wA7T7-0000000132G-2iBh for pgsql-hackers@postgresql.org; Tue, 07 Apr 2026 14:31:54 +0000 Received: from phl-compute-06.internal (phl-compute-06.internal [10.202.2.46]) by mailfout.stl.internal (Postfix) with ESMTP id A42611D0018F; Tue, 7 Apr 2026 10:31:51 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-06.internal (MEProxy); Tue, 07 Apr 2026 10:31:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=eisentraut.org; h=cc:cc:content-transfer-encoding:content-type:content-type :date:date:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:subject:subject:to:to; s=fm1; t=1775572311; x=1775658711; bh=M48YAEq3x2ursVhitphKKBTtCJM+C7T5 1CrcjzWA7Gs=; b=TTP8v6qR+mRGJs+/n9hQVryaIbTHYO9qLFLj1i8kv1gq4Mvb xzL5nrZqcJgJu7Ub/CwTNlDVaK0Nwtdhp/V1WHnoevroZEHHNhSVfAgBcaVq3kaN D4V40C8N+WxnXouQNRqM3yH3UNbSt2HHcE7pKttEfxxHw1VejYTYWDKvaBzRv27f NsqwxriQJD7Hd6Z1vJUVGzvrBs6pmn8hTGBVI1tF4OzQTbPQ8ub+BHwAfS1rggfW 5GkYL+u181uOsathaCeNBRwCN9TssvgwjQ4bXUU9773FtuUXD85FTYHdYnSPF1rR sf/TBELSy5AF8/mNnrR0lO74ag6xrAZNLaTn7Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1775572311; x= 1775658711; bh=M48YAEq3x2ursVhitphKKBTtCJM+C7T51CrcjzWA7Gs=; b=p 8LFfM0qt11dl0UiQxKL9pci+UCaK2QAYvbDxJ6SjTiUIFSqVPHfhIvBHayAlGiFA 45xRyjGGU5qNvCVRCOgN3hH9UIDC9MT+6bYNF48cWu17LOu9tH/bikhdTRzjNH2j hm1JDHnYvBwKZPfKIu7ph9LXxHXM5LuocWmshbWXgaQ4REsqDgegLFmSlhNV48Zl 5D3jBeQIqblBx+agjnLATy3OvWzzsUWQLavm5GspAc9YVurDTrothDeTuoWAjp1C cNZfEaAMgj3H3k9iwFOFhz/Hdlbz98QisZJPq45DaEypI8QkZwkrnOKUJo7oUrcz Ra2FVgg222i6k6FUmKLFQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefhedrtddtgddvtdeklecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecunecujfgurhepkfffgggfuffvvehfhfgjtgfgsehtjeertd dtvdejnecuhfhrohhmpefrvghtvghrucfgihhsvghnthhrrghuthcuoehpvghtvghrsegv ihhsvghnthhrrghuthdrohhrgheqnecuggftrfgrthhtvghrnhephfehheelkeefleeuke dtfefhieekieetheehueethfetvdeugeeihfeiudegkedtnecuffhomhgrihhnpehllhhv mhdrohhrghenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhroh hmpehpvghtvghrsegvihhsvghnthhrrghuthdrohhrghdpnhgspghrtghpthhtohepfedp mhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepthhglhesshhsshdrphhghhdrphgrrd hushdprhgtphhtthhopehpohhsthhgrhgvshesjhgvlhhtvghfrdhnlhdprhgtphhtthho pehpghhsqhhlqdhhrggtkhgvrhhssehpohhsthhgrhgvshhqlhdrohhrgh X-ME-Proxy: Feedback-ID: ie0a040ee:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 7 Apr 2026 10:31:50 -0400 (EDT) Message-ID: <94a2bc01-e1bf-4e07-ba58-18dc5aacc0e9@eisentraut.org> Date: Tue, 7 Apr 2026 16:31:49 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: enable fallthrough warnings on clang To: Tom Lane Cc: Jelte Fennema-Nio , pgsql-hackers References: <76a8efcd-925a-4eaf-bdd1-d972cd1a32ff@eisentraut.org> <955ddaa3-d6e8-4d87-a368-ef9f25960d4e@eisentraut.org> <1914806.1775511109@sss.pgh.pa.us> Content-Language: en-US From: Peter Eisentraut In-Reply-To: <1914806.1775511109@sss.pgh.pa.us> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 06.04.26 23:31, Tom Lane wrote: > Peter Eisentraut writes: >> I have committed this patch set. I also added a test into the C++ module. > > BF member ayu is failing said test: > > > ccache clang++-4.0 -std=gnu++11 -Wall -Wpointer-arith -Werror=vla -Wmissing-format-attribute -Wimplicit-fallthrough -Wformat-security -fno-strict-aliasing -fwrapv -g -O2 -fPIC -fvisibility=hidden -fvisibility-inlines-hidden -I. -I. -I../../../../src/include -D_GNU_SOURCE -I/usr/include/libxml2 -c -o test_cplusplusext.o test_cplusplusext.cpp > test_cplusplusext.cpp:66:3: warning: unannotated fall-through between switch labels [-Wimplicit-fallthrough] > case 2: > ^ > test_cplusplusext.cpp:66:3: note: insert '[[clang::fallthrough]];' to silence this warning > case 2: > ^ > [[clang::fallthrough]]; > test_cplusplusext.cpp:66:3: note: insert 'break;' to avoid fall-through > case 2: > ^ > break; > 1 warning generated. > > > I don't know if it's worth catering to this extremely old > clang version ... It appears that we could satisfy clang 6 through 9 with something like #elif defined(__clang__) #define pg_fallthrough [[clang::fallthrough]] #else Clang >=10 support the existing #elif __has_attribute(fallthrough) branch. But AFAICT, clang 5 and older are completely broken in this regard, because they react to the presence of [[clang::fallthrough]] with a syntax error ("error: expected expression"). Not even clang's own example code[0] works. [0]: https://releases.llvm.org/5.0.2/tools/clang/docs/AttributeReference.html#fallthrough-clang-fallthrough Also, this only appears to affect C++. In C mode, before clang 10, the warning option -Wimplicit-fallthrough doesn't appear to do anything.