Re: fix more casting away of qualifiers

From: Peter Eisentraut <peter(at)eisentraut(dot)org>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: fix more casting away of qualifiers
Date: 2026-09-15 08:03:57
Message-ID: c76b72dd-5736-453a-b698-6968d42e4768@eisentraut.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 18.08.26 11:04, Peter Eisentraut wrote:
> The attached patches fix more cases where qualifiers (const, volatile)
> are cast away either accidentally, or unnecessarily, or where it can be
> worked around easily.
>
> I split these into tiny bits to simplify review and to show that they
> are all independent.  But they could perhaps be committed all together.
> (See also similar commit 3f988629805.)
>
> I have a local WIP branch that fixes all remaining -Wcast-qual warnings.
>  The attached patches are the "easy" half of that.  I plan to propose
> addressing the other half separately later.

Here are more patches for this. (I suppose this is half of the
above-mentioned other half.)

The first two patches address the issue that unconstify cannot be used
for global variables. I'm introducing an unconstify_constexpr that can
be used for that but only works for GCC.

The third patch adjusts unconstify, unconstify_constexpr, and unvolatize
so that they don't trigger -Wcast-qual warnings. This will be useful
later when we have fixed all the remaining issues and we can turn on
-Wcast-qual.

Patches 4 through 7 add various unconstify and unvolatize in place of or
in addition to existing casts.

The last patch would then turn on the warning option, but it's only for
illustration right, as there is more (increasingly complicated) stuff to
fix after this.

Attachment Content-Type Size
v2-0001-Add-unconstify_constexpr.patch text/plain 2.7 KB
v2-0002-Use-unconstify_constexpr.patch text/plain 3.6 KB
v2-0003-Adjust-unconstify-unvolatize-to-avoid-Wcast-qual-.patch text/plain 1.6 KB
v2-0004-Fix-Wcast-qual-warnings-with-external-APIs.patch text/plain 3.8 KB
v2-0005-Change-float-4-8-in_internal-take-const-char-inpu.patch text/plain 5.1 KB
v2-0006-Convert-some-casts-to-unconstify.patch text/plain 4.4 KB
v2-0007-Additional-unvolatize-uses.patch text/plain 3.0 KB
v2-0008-WIP-Add-warning-option-Wcast-qual.patch text/plain 1.8 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Wei Sun 2026-09-15 08:05:46 Severe performance degradation with concurrent updates due to excessive EvalPlanQual (EPQ) re‑evaluation
Previous Message Ayush Tiwari 2026-09-15 08:00:36 Re: FIX: BUG #19687: ALTER SEQUENCE missing lock