pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Peter Eisentraut <peter@eisentraut.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Refactor static_assert() support.
Date: Mon, 15 Dec 2025 10:55:20 +0000
Message-ID: <E1vV6EZ-000tOV-1M@gemulon.postgresql.org> (raw)

Refactor static_assert() support.

HAVE__STATIC_ASSERT was really a test for GCC statement expressions,
as needed for StaticAssertExpr() now that _Static_assert could be
assumed to be available through our C11 requirement.  This
artificially prevented Visual Studio from being able to use
static_assert() in other contexts.

Instead, make a new test for HAVE_STATEMENT_EXPRESSIONS, and use that
to control only whether StaticAssertExpr() uses fallback code, not the
other variants.  This improves the quality of failure messages in the
(much more common) other variants under Visual Studio.

Also get rid of the two separate implementations for C++, since the C
implementation is also also valid as C++11.  While it is a stretch to
apply HAVE_STATEMENT_EXPRESSIONS tested with $CC to a C++ compiler,
the previous C++ coding assumed that the C++ compiler had them
unconditionally, so it isn't a new stretch.  In practice, the C and
C++ compilers are very likely to agree, and if a combination is ever
reported that falsifies this assumption we can always reconsider that.

Author: Thomas Munro <thomas.munro@gmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/CA%2BhUKGKvr0x_oGmQTUkx%3DODgSksT2EtgCA6LmGx_jQFG%3DsDUpg%40mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/17f446784d54da827f74c2acc0fa772a41b92354

Modified Files
--------------
config/c-compiler.m4       | 26 +++++++++++---------------
configure                  | 18 +++++++++---------
configure.ac               |  2 +-
meson.build                | 10 +++-------
src/include/c.h            | 45 ++++++++++++---------------------------------
src/include/pg_config.h.in |  6 +++---
6 files changed, 39 insertions(+), 68 deletions(-)



Message-ID: <E1vV6EZ-000tOV-1M@gemulon.postgresql.org>
Permalink:  ../E1vV6EZ-000tOV-1M@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1vV6EZ-000tOV-1M@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: peter@eisentraut.org, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Refactor static_assert() support.
  In-Reply-To: <E1vV6EZ-000tOV-1M@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox