remove pg_restrict workaround
Peter Eisentraut <peter@eisentraut.org>
From: Peter Eisentraut <peter@eisentraut.org>
To: pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2025-10-15T13:06:18Z
Lists: pgsql-hackers
Attachments
- 0001-Remove-meaninglist-restrict-qualifiers.patch (text/plain) patch 0001
- 0002-Replace-pg_restrict-by-standard-restrict.patch (text/plain) patch 0002
When in C11 mode, MSVC supports the standard "restrict" keyword, so we don't need the workaround with using "pg_restrict" instead anymore. (Just for clarification, restrict is a C99 feature, but MSVC only accepts it properly in C11 mode.) So I'm proposing to remove that workaround here, so that code can use the standard restrict keyword without having to worry about the alternative spelling. However, "restrict" does not exist in C++, but all supported compilers support the spelling "__restrict" in C++. Therefore, I'm leaving in place the Autoconf test and the equivalent Meson business, to maintain the status quo with respect to C++. I'm updating the comments about that a bit. (In a C++-free world, we could have plausibly removed the Autoconf test altogether.) While making the required adjustments, I found a few pieces of code that use restrict (previously pg_restrict) in what appears to me to be nonsensical ways, like memcpy((char *pg_restrict) (buf->data + buf->len), &ni, sizeof(uint16)); The restrict qualifier is not meaningful in casts, so I'm confused about why it is used here. I did not find any indications either in the old discussions leading up to this change or on the wider web that there are any other interpretations or compiler extensions or perhaps a C++ angle that would make this meaningful. Also, the generated code appears to be the same if I remove this. So I'm proposing to remove redundant casts like this.
Commits
-
Revert "Replace pg_restrict by standard restrict"
- fa16e7fd8488 19 (unreleased) landed
-
Replace pg_restrict by standard restrict
- f0f2c0c1aef9 19 (unreleased) landed
-
Remove meaninglist restrict qualifiers
- 64d2b0968ea4 19 (unreleased) landed