Replace __builtin_types_compatible_p with _Generic
commit : d15a6bc2e16d4b330d6d455e41ce1ab3395d8e03
author : Peter Eisentraut <peter@eisentraut.org>
date : Tue, 14 Jul 2026 10:28:04 +0200
committer: Peter Eisentraut <peter@eisentraut.org>
date : Tue, 14 Jul 2026 10:28:04 +0200
Click here for diff
_Generic is the C11 standard equivalent (and superset) of
__builtin_types_compatible_p, so by replacing the latter with the
former, we can now rely on this working on all compilers, instead of
previously just with GCC-compatible ones. And we can drop a configure
test.
This affects StaticAssertVariableIsOfType() and
StaticAssertVariableIsOfTypeMacro() and indirectly unconstify() and
unvolatize().
Neither _Generic nor __builtin_types_compatible_p works in C++, so
this does not change that, but this adds an explicit code comment
about that.
There are some subtle behavior changes, but these do not affect cases
that are in use or likely to be useful. _Generic does lvalue
conversion on the controlling expression, which means it drops
top-level qualifiers and converts arrays to pointers.
__builtin_types_compatible_p on the other hand, supports arrays and
just ignores qualifiers. So before, StaticAssertVariableIsOfType(x,
const int) might have worked, but now it does not. (But note that it
would previously have succeeded even if x was a non-const int, so this
usage would always have been dubious.) Also,
StaticAssertVariableIsOfType(y, char[]) would have worked, but now you
need to write char *. (But this is not backward compatible, because
char * would previously not have succeeded.) Similarly, unconstify of
non-pointers, like unconstify(const int, x) would previously have
worked, but this was just by accident and never useful (you can just
assign directly, without a cast), and the C++ implementation rejects
non-pointers anyway. Some comments are added to explain this a bit.
There are no current uses affected by this.
Note that even though we have required C11 since f5e0186f865, we have
not made use of _Generic until now (except in an MSVC-specific case in
commit 59c2f03d1ec). This now raises the effective compiler
requirement on the trailing edge slightly from GCC 4.8 to GCC 4.9.
This in turn means that we effectively drop support for RHEL 7.
Author: Peter Eisentraut <peter@eisentraut.org>
Co-authored-by: Thomas Munro <thomas.munro@gmail.com>
Co-authored-by: Jelte Fennema-Nio <postgres@jeltef.nl>
Discussion: https://www.postgresql.org/message-id/flat/CA+hUKGL7trhWiJ4qxpksBztMMTWDyPnP1QN+Lq341V7QL775DA@mail.gmail.com
M config/c-compiler.m4
M configure
M configure.ac
M meson.build
M src/include/c.h
M src/include/pg_config.h.in
Stamp 19beta2.
commit : 7873db5369b967dd53984df34fd800003410d04f
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 13 Jul 2026 16:03:24 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 13 Jul 2026 16:03:24 -0400
Click here for diff
M configure
M configure.ac
M meson.build
Translation updates
commit : 8055e3375aa1c2237181e06be26b05b964d18ed5
author : Peter Eisentraut <peter@eisentraut.org>
date : Mon, 13 Jul 2026 12:03:36 +0200
committer: Peter Eisentraut <peter@eisentraut.org>
date : Mon, 13 Jul 2026 12:03:36 +0200
Click here for diff
Stamp 14.23.
commit : 4e1a23c0ea0be0214c6806baa212886cee8f14a6
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 11 May 2026 15:51:39 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 11 May 2026 15:51:39 -0400
Click here for diff
M configure
M configure.ac
Last-minute updates for release notes.
commit : 93741c9db09709ebe05d5f59ee7852c3ad4981a9
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 11 May 2026 14:54:40 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 11 May 2026 14:54:40 -0400
Click here for diff
Stamp 15.18.
commit : 005c1971a2926fbb9caf5a1ad634cd17a42bfd3c
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 11 May 2026 15:49:58 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 11 May 2026 15:49:58 -0400
Click here for diff
M configure
M configure.ac
Last-minute updates for release notes.
commit : 78f1b471f991307cea4aa0d95f2d957601a1b8cd
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 11 May 2026 14:54:40 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 11 May 2026 14:54:40 -0400
Click here for diff
Stamp 16.14.
commit : 0d1c00c624fa7367d4a895f44381887757289682
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 11 May 2026 15:48:18 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 11 May 2026 15:48:18 -0400
Click here for diff
M configure
M configure.ac
M meson.build
Last-minute updates for release notes.
commit : 878e171244f7c1280201a04aa420b78c4a2d08d3
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 11 May 2026 14:54:40 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 11 May 2026 14:54:40 -0400
Click here for diff
Stamp 17.10.
commit : 25c49f3a4a742ba283f5cc43cc7f1d361552e917
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 11 May 2026 15:46:41 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 11 May 2026 15:46:41 -0400
Click here for diff
M configure
M configure.ac
M meson.build
Last-minute updates for release notes.
commit : 25d938dbcb19ba172068159c0f22826d7cc681ea
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 11 May 2026 14:54:40 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 11 May 2026 14:54:40 -0400
Click here for diff
Stamp 18.4.
commit : f5cc81719e6da4cbdb1f797c48b693e91018153a
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 11 May 2026 15:44:35 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 11 May 2026 15:44:35 -0400
Click here for diff
M configure
M configure.ac
M meson.build
Last-minute updates for release notes.
commit : bbd12e8010561dab2c745d2ece0e94d102bef2ea
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 11 May 2026 14:54:40 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 11 May 2026 14:54:40 -0400
Click here for diff
Stamp 14.22.
commit : 966473719c7f8067848dc79b58da0fb17ed136b1
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 23 Feb 2026 17:03:30 -0500
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 23 Feb 2026 17:03:30 -0500
Click here for diff
M configure
M configure.ac
Translation updates
commit : 7917762558545fbe16c0c9e9b97b83a30c11eaa8
author : Peter Eisentraut <peter@eisentraut.org>
date : Mon, 23 Feb 2026 14:06:33 +0100
committer: Peter Eisentraut <peter@eisentraut.org>
date : Mon, 23 Feb 2026 14:06:33 +0100
Click here for diff
Stamp 15.17.
commit : 3eb6f61958ac5027a18791a828a0c7a47accf211
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 23 Feb 2026 17:01:47 -0500
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 23 Feb 2026 17:01:47 -0500
Click here for diff
M configure
M configure.ac
Translation updates
commit : 7063b9e92b25caaa27c8cc4ec37ef85fe9e63cb7
author : Peter Eisentraut <peter@eisentraut.org>
date : Mon, 23 Feb 2026 14:03:47 +0100
committer: Peter Eisentraut <peter@eisentraut.org>
date : Mon, 23 Feb 2026 14:03:47 +0100
Click here for diff
Stamp 16.13.
commit : 776479eed63aac4185e57adaf7db1ce0810a4d3e
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 23 Feb 2026 17:00:20 -0500
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 23 Feb 2026 17:00:20 -0500
Click here for diff
M configure
M configure.ac
M meson.build
Translation updates
commit : 96802648aa2fc114f1d8728540494e422059b9ab
author : Peter Eisentraut <peter@eisentraut.org>
date : Mon, 23 Feb 2026 14:02:22 +0100
committer: Peter Eisentraut <peter@eisentraut.org>
date : Mon, 23 Feb 2026 14:02:22 +0100
Click here for diff