Use standard C23 and C++ attributes if available

Started by Peter Eisentraut7 months ago2 messageshackers
Beta feature

Hackorum builds and tests every patch posted to the lists, not only commitfest submissions. This is Hackorum's own CI rather than the PostgreSQL project's, and it is still under testing - please report anything that looks wrong.

won't retrysuccessCI history

You can run a PostgreSQL built from this patch straight from Docker, with no checkout and no build:

docker run --rm -p 5432:5432 ghcr.io/hackorum-dev/postgres-patch:t53358
psql -h localhost -U postgres

Built from patchset v1 (message #1), July 27, 2026 at 03:54 AM.

Every patchset is also pushed to a branch of our PostgreSQL fork, so you can check out the same tree CI built. Without a PostgreSQL checkout:

git clone --branch t53358_1 https://github.com/hackorum-dev/postgres.git

In a checkout you already have, add the fork once:

git remote add hackorum https://github.com/hackorum-dev/postgres.git

then, for this patchset and every later one:

git fetch hackorum t53358_1 && git checkout t53358_1

Patchset v1 (message #1) is on t53358_1

Jump to latest
#1Peter Eisentraut
peter_e@gmx.net

This is related to the C++ compatibility work in [0]/messages/by-id/df78eaac-c2eb-4344-852e-0965c75c5ad6@eisentraut.org.

This patch proposes to use the standard C23 and C++ attributes
[[nodiscard]], [[noreturn]], and [[maybe_unused]], if available.

The immediate practical impact is that for pg_noreturn, we can drop the
GCC-specific and MSVC-specific fallbacks, because the C11 and the C++
implementation will now cover all required cases.

For the other two attributes, this makes them available in
not-GCC-compatible compilers that support C23 as well as in C++. This
set is theoretical at the moment, but it might become more practical if
either MSVC gets some C23 support or we improve the support for C++
extensions with MSVC (see also [0]/messages/by-id/df78eaac-c2eb-4344-852e-0965c75c5ad6@eisentraut.org).

[0]: /messages/by-id/df78eaac-c2eb-4344-852e-0965c75c5ad6@eisentraut.org
/messages/by-id/df78eaac-c2eb-4344-852e-0965c75c5ad6@eisentraut.org

Attachments:

t53358_1
0001-Use-standard-C23-and-C-attributes-if-available.patchtext/plain; charset=UTF-8; name=0001-Use-standard-C23-and-C-attributes-if-available.patchDownload+25-20
#2Peter Eisentraut
peter_e@gmx.net
In reply to: Peter Eisentraut (#1)
Re: Use standard C23 and C++ attributes if available

On 19.02.26 09:54, Peter Eisentraut wrote:

This is related to the C++ compatibility work in [0].

This patch proposes to use the standard C23 and C++ attributes
[[nodiscard]], [[noreturn]], and [[maybe_unused]], if available.

The immediate practical impact is that for pg_noreturn, we can drop the
GCC-specific and MSVC-specific fallbacks, because the C11 and the C++
implementation will now cover all required cases.

For the other two attributes, this makes them available in not-GCC-
compatible compilers that support C23 as well as in C++.  This set is
theoretical at the moment, but it might become more practical if either
MSVC gets some C23 support or we improve the support for C++ extensions
with MSVC (see also [0]).

[0]: /messages/by-id/df78eaac-
c2eb-4344-852e-0965c75c5ad6%40eisentraut.org

This has been committed. Note that the C++ extension support with MSVC
exists now, so this patch has some utility for that.