v9-0003-Make-unconstify-and-unvolatize-use-StaticAssertVa.patch
text/x-patch
Filename: v9-0003-Make-unconstify-and-unvolatize-use-StaticAssertVa.patch
Type: text/x-patch
Part: 2
Message:
Re: Make copyObject work in C++
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: format-patch
Series: patch v9-0003
Subject: Make unconstify and unvolatize use StaticAssertVariableIsOfTypeMacro
| File | + | − |
|---|---|---|
| src/include/c.h | 3 | 10 |
From 37021f7b2cae580ca348c8600f9644f928b48232 Mon Sep 17 00:00:00 2001 From: Jelte Fennema-Nio <postgres@jeltef.nl> Date: Thu, 19 Feb 2026 23:55:43 +0100 Subject: [PATCH v9 3/3] Make unconstify and unvolatize use StaticAssertVariableIsOfTypeMacro The unconstify and unvolatize macros had an almost identical assertion as was already defined in StaticAssertVariableIsOfTypeMacro, only it had a less useful error message and didn't have a sizeof fallback. --- src/include/c.h | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/include/c.h b/src/include/c.h index 07e931a6c89..5fa366914d8 100644 --- a/src/include/c.h +++ b/src/include/c.h @@ -1273,20 +1273,13 @@ typedef struct PGAlignedXLogBlock PGAlignedXLogBlock; #if defined(__cplusplus) #define unconstify(underlying_type, expr) const_cast<underlying_type>(expr) #define unvolatize(underlying_type, expr) const_cast<underlying_type>(expr) -#elif defined(HAVE__BUILTIN_TYPES_COMPATIBLE_P) +#else #define unconstify(underlying_type, expr) \ - (StaticAssertExpr(__builtin_types_compatible_p(typeof(expr), const underlying_type), \ - "wrong cast"), \ + (StaticAssertVariableIsOfTypeMacro(expr, const underlying_type), \ (underlying_type) (expr)) #define unvolatize(underlying_type, expr) \ - (StaticAssertExpr(__builtin_types_compatible_p(typeof(expr), volatile underlying_type), \ - "wrong cast"), \ + (StaticAssertVariableIsOfTypeMacro(expr, volatile underlying_type), \ (underlying_type) (expr)) -#else -#define unconstify(underlying_type, expr) \ - ((underlying_type) (expr)) -#define unvolatize(underlying_type, expr) \ - ((underlying_type) (expr)) #endif /* -- 2.53.0