From 96abbe2a162587228b5b41b64e9576ffac000633 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Tue, 3 Nov 2026 15:39:36 +0100 Subject: [PATCH 09/10] Adjust unconstify/unvolatize to avoid -Wcast-qual warnings An intermediate cast to uintptr_t avoids the warning. That way, we could turn on -Wcast-qual, and all unconstify() and unvolatize() uses would pass but bare casts that discard qualifiers would raise warnings. Reviewed-by: Rui Zhao Discussion: https://www.postgresql.org/message-id/c76b72dd-5736-453a-b698-6968d42e4768%40eisentraut.org --- src/include/c.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/include/c.h b/src/include/c.h index 79b82226551..d4699a4a271 100644 --- a/src/include/c.h +++ b/src/include/c.h @@ -1453,22 +1453,22 @@ typedef struct PGAlignedXLogBlock PGAlignedXLogBlock; #else /* !__cplusplus */ #define unconstify(underlying_type, expr) \ (StaticAssertVariableIsOfTypeMacro(expr, const underlying_type), \ - (underlying_type) (expr)) + (underlying_type) (uintptr_t) (expr)) #define unconstify_pointee(pointee_type, expr) \ (StaticAssertVariableIsOfTypeMacro(expr, pointee_type const *), \ - (pointee_type *) (expr)) + (pointee_type *) (uintptr_t) (expr)) #define unvolatize(underlying_type, expr) \ (StaticAssertVariableIsOfTypeMacro(expr, volatile underlying_type), \ - (underlying_type) (expr)) + (underlying_type) (uintptr_t) (expr)) #ifdef __GNUC__ #define unconstify_constexpr(underlying_type, expr) \ __builtin_choose_expr( \ _Generic((expr), const underlying_type: 1, default: 0), \ - (underlying_type) (expr), \ + (underlying_type) (uintptr_t) (expr), \ (void) 0) #else /* !__GNUC_ */ #define unconstify_constexpr(underlying_type, expr) \ - ((underlying_type) (expr)) + ((underlying_type) (uintptr_t) (expr)) #endif /* !__GNUC_ */ #endif /* !__cplusplus */ -- 2.56.0