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 1vzW9Y-0014rp-1M for pgsql-hackers@arkaria.postgresql.org; Mon, 09 Mar 2026 08:39:52 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vzW9U-00F09m-36 for pgsql-hackers@arkaria.postgresql.org; Mon, 09 Mar 2026 08:39:49 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vzW9T-00F09d-39 for pgsql-hackers@lists.postgresql.org; Mon, 09 Mar 2026 08:39:49 +0000 Received: from fhigh-b4-smtp.messagingengine.com ([202.12.124.155]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1vzW9Q-00000001le5-3Wlu for pgsql-hackers@lists.postgresql.org; Mon, 09 Mar 2026 08:39:47 +0000 Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailfhigh.stl.internal (Postfix) with ESMTP id BBE057A0060; Mon, 9 Mar 2026 04:39:41 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-04.internal (MEProxy); Mon, 09 Mar 2026 04:39:41 -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=fm3; t=1773045581; x=1773131981; bh=Sn0TRbT702HKxb3Bac4iRkwYxwoWfqWE va6fWDOtwCA=; b=cnli50MAeTfbQo6XQki/H1/0tNNRRtw+hx4KyaCaUX0mMxqE VJ1/R4pz18OSO3uOGEkYMn8ImsxVHCoVrwsRy4XDddnbOfAZwSsYd61nnw19666w Xee29/cFdEZ36OfD12Fsr/SyPJyR8sTqbdc/fjFEHKJhaGawJUtXu70t9gQx9mcA P26oiZDlKht0LUdNuifsU8ZEPfSAqmZ1IX1WEMbhu0xhnevd9QNUY244q//E4zlB x1jk/Qf6ER3SQPGmpbY1IXBbVBP0d+mVtn54ZOL01cPKoBFXzp9+S33ThJVYTY5H RmxwXF7dbhCK+sYb9evJIVJo9343oMYPq3BJqg== 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=fm1; t=1773045581; x= 1773131981; bh=Sn0TRbT702HKxb3Bac4iRkwYxwoWfqWEva6fWDOtwCA=; b=n 5AD2V2PcUP0rK4oCsoKpIUOA8BwNlL+ZJWB71KLfaE90JHmqTvod+HsrLH1aenuk P+/CpY67oxaCVa7i7axvgyxu+rt0eSW5ynLqO4BzWQMYyvuRfiePx8+ENyWqKAfe Or3KjVU0XI87722naizn/7FU1W6ps3sNucHlmhHpIjPb2CKZiPmAtV1h1m+JxPUQ oKIxk817hWqjWwR00tcgaq+08nb5aSONMCqEejoydexnNTHlAy0oVNKcR1Nbq+H7 oBKml9pZZeZx3NcU5Cv0zxy9yVYKSGBdrJn1UdJvmOQ/uw/HXuSI0Ore13JcWGYh FsUY19QevyTB5AvUX8udA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvjeejieehucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhepkfffgggfuffhvfevfhgjtgfgsehtkeertddtvdejnecuhfhrohhmpefrvghtvghr ucfgihhsvghnthhrrghuthcuoehpvghtvghrsegvihhsvghnthhrrghuthdrohhrgheqne cuggftrfgrthhtvghrnhepvdejiefhhfdvfeehveelkeevueejhfeiudeuleejkeeijeei geefhfdthfeljeegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilh hfrhhomhepphgvthgvrhesvghishgvnhhtrhgruhhtrdhorhhgpdhnsggprhgtphhtthho peefpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopehpohhsthhgrhgvshesjhgvlh htvghfrdhnlhdprhgtphhtthhopehpghhsqhhlqdhhrggtkhgvrhhssehlihhsthhsrdhp ohhsthhgrhgvshhqlhdrohhrghdprhgtphhtthhopehthhhomhgrshdrmhhunhhrohesgh hmrghilhdrtghomh X-ME-Proxy: Feedback-ID: ie0a040ee:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 9 Mar 2026 04:39:40 -0400 (EDT) Message-ID: <9770b32b-84d4-4a36-9ff6-8fb54144cd24@eisentraut.org> Date: Mon, 9 Mar 2026 09:39:38 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Make copyObject work in C++ From: Peter Eisentraut To: Jelte Fennema-Nio Cc: PostgreSQL Hackers , Thomas Munro References: <4d8b9e53-3f37-43f0-a4aa-5bda9c7961b3@eisentraut.org> <4e82f77b-acad-4356-94f6-8255135fb36b@eisentraut.org> <2h2n2gyw2f4ucicbl3drtdkjt2wzf6b2r4wqm7xwks6vpx5j7n@imymv4hkz5jz> <8f8776be-6d8f-4e1c-8d21-e55052edd91b@eisentraut.org> Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 06.03.26 10:23, Peter Eisentraut wrote: > On 02.03.26 11:56, Peter Eisentraut wrote: >> On 27.02.26 17:40, Jelte Fennema-Nio wrote: >>> On Fri Feb 20, 2026 at 10:47 AM CET, Jelte Fennema-Nio wrote: >>>> Makes total sense, I didn't realise decltype and typeof were not quite >>>> the same thing. Attached is an updated patchset that does that. >>> >>> Same patchset as before, but now also including a C++ fallback for >>> __builtin_types_compatible_p. >> >> I have committed v10-0001.  Now let's give the buildfarm a few days. > > I have committed v10-0002 and v10-0003 now.  I will look at the > remaining patch in a few days. Thoughts on v10-0004: It's not clear to me to what extent StaticAssertVariableIsOfType would be useful in C++. There are two general areas where it is used. One, when multiple separate extensions want to talk to each other, to check the types of certain entry point variables, such as plpython/hstore_plpython. And two, in some macro-based template libraries such as lib/ilist.h and lib/pairingheap.h. You add a lot of tests, but do they cover these particular use scenarios? In either case, it might be better to create a test on that level and then see what we'd need to make happen to have it working under C++. There is lots of trickery involved there, so it's not clear whether it works out of the box in C++ already. Are there any of these that you are particularly interested in for your work? About the specific implementation, I'm hesitant to build this on top of __builtin_types_compatible_p(). Aside from the ugliness of redefining a symbol that starts with __builtin_*, I think we should really work to get rid of __builtin_types_compatible_p() and replace it with _Generic, which would be portable beyond GCC. How about we make a pg_types_compatible_p(), which would look like this: #if defined(__cplusplus) // your C++ code here #else if defined(HAVE__GENERIC) // C code using _Generic here #else // C code using __builtin_types_compatible_p here #endif We can require that a supported C compiler must support either _Generic or __builtin_types_compatible_p, so we don't need any further fallback. (So we could remove the configure test of __builtin_types_compatible_p, but we'd add one for _Generic.) And in a few years we could even remove the __builtin_types_compatible_p fallback.