Skip to content

Fix regression tests against PostgreSQL 19 and also fix build warnings - #59

Merged
dvarrazzo merged 2 commits into
dvarrazzo:masterfrom
devrimgunduz:master
Jul 25, 2026
Merged

Fix regression tests against PostgreSQL 19 and also fix build warnings#59
dvarrazzo merged 2 commits into
dvarrazzo:masterfrom
devrimgunduz:master

Conversation

@devrimgunduz

Copy link
Copy Markdown
Contributor

Hi @dvarrazzo ,

Attached are patches against master that fixes regression tests against PG 19 and also fixes build warnings against all recent PostgreSQL versions.

Cheers, Devrim

Per: pgdg-packaging/pgdg-rpms#213

@dvarrazzo

Copy link
Copy Markdown
Owner

Thank you @devrimgunduz I'll try to put together a package for v19 🙂

Building pgmp against recent PostgreSQL versions produces a number of
warnings enabled by PGXS's default `CFLAGS`
(`-Wmissing-variable-declarations`, and, on `clang`,
`-Wdefault-const-init-var-unsafe`). None of them point to an actual bug,
but they are worth cleaning up so the module builds warning-free again.

* **`-Wmissing-variable-declarations` on `_pgmp_limb_0` / `_pgmp_limb_1`
  (src/pgmp.c)**

  These two file-scope constants are defined in `pgmp.c` and referenced
  from `pmpq.c` and `pmpz.c` via ad-hoc local `extern` declarations, but
  there was no declaration visible *before* the point where they are
  actually defined in `pgmp.c` itself, which is what the warning flags.
  Moved the `extern` declarations into `pgmp-impl.h` (already included by
  all three files) and dropped the now-redundant local `extern`s from
  `pmpq.c` and `pmpz.c`.

* **`-Wmissing-variable-declarations` on `pgmp_randstate`
  (src/pmpz_rand.c)**

  `pgmp_randstate` is only ever used inside `pmpz_rand.c`, so instead of
  adding a pointless header declaration it is simply declared `static`,
  which also documents that it's private module state.

* **`-Wdefault-const-init-var-unsafe` on `const mpz_t` / `const mpq_t`
  locals (all `pmp[zq]*.c` files)**

  Every wrapper function (and the macros that generate them) declares its
  GMP arguments as `const mpz_t`/`const mpq_t` with no initializer; the
  struct is instead populated a few lines later by `mpz_from_pmpz()` /
  `mpq_from_pmpq()`, which take a `const` pointer but fill it in through a
  local non-const alias (see the comment in `pmpz.c`/`pmpq.c`). This is
  intentional and safe (the values are never read before being
  populated), but newer compilers warn that a `const`-qualified
  aggregate with no explicit initializer is left "uninitialized".

  Added an explicit `= {0}` zero-initializer to every such declaration.
  This is a no-op at runtime (the values are overwritten by
  `mpz_from_pmpz()`/`mpq_from_pmpq()` before use in every case) and
  silences the warning without changing any behaviour.

No functional/behavioural change is introduced by this patch; it is
warnings-only.

Coded by Claude, tested by me.
@dvarrazzo
dvarrazzo merged commit 323f546 into dvarrazzo:master Jul 25, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants