From 8e47c0d842fc8e41343ba5307d6ea4db4c20225d Mon Sep 17 00:00:00 2001 From: Lev Nachmanson Date: Wed, 11 Mar 2026 12:42:39 -1000 Subject: [PATCH] Fixed the assertion violation in `mpz.cpp:602` when running with `-tr:arith`. **Root cause**: `vector::resize(SZ s, Args args...)` in `src/util/vector.h` took `args` by value and used `std::forward(args)` in a loop. The first iteration moved from `args`, leaving all subsequent elements with a moved-from state (`rational{0/0}` instead of `rational{0/1}`). This corrupted the coefficient vector in the pretty printer, causing a division-by-zero assertion when multiplying. **Fix**: Changed `resize` to take `Args const& args` and copy-construct each element instead of forwarding/moving. --- src/util/vector.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/util/vector.h b/src/util/vector.h index 8d1632ced..41f81fc95 100644 --- a/src/util/vector.h +++ b/src/util/vector.h @@ -494,7 +494,7 @@ public: } template - void resize(SZ s, Args args...) { + void resize(SZ s, Args const& args) { SZ sz = size(); if (s <= sz) { shrink(s); return; } while (s > capacity()) { @@ -505,7 +505,7 @@ public: iterator it = m_data + sz; iterator end = m_data + s; for (; it != end; ++it) { - new (it) T(std::forward(args)); + new (it) T(args); } }