3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2026-08-02 20:23:27 +00:00
z3/src/math
Nikolaj Bjorner bffbe2475f
Fix reversed precondition assertion in grobner::pop_scope (#10318)
### What it does

Fixes an inverted precondition assertion in `grobner::pop_scope`
(`src/math/grobner/grobner.cpp`).

```cpp
void grobner::pop_scope(unsigned num_scopes) {
    SASSERT(num_scopes >= get_scope_level());          // was reversed
    unsigned new_lvl = get_scope_level() - num_scopes; // requires num_scopes <= level
    ...
    m_scopes.shrink(new_lvl);
}
```

`get_scope_level()` returns `m_scopes.size()` (grobner.h). The body
computes
`new_lvl = get_scope_level() - num_scopes` and calls
`m_scopes.shrink(new_lvl)`,
which is only well-defined when `num_scopes <= get_scope_level()`. The
assertion
stated the opposite (`>=`), so in debug builds it would fire on any
valid partial
pop (e.g. popping one of several scopes) while failing to catch the
unsigned
underflow it was meant to guard against. Changed to `<=`.

### Evidence

- `get_scope_level() const { return m_scopes.size(); }`
(`src/math/grobner/grobner.h`).
- Compiled the translation unit with MSVC and `Z3DEBUG` defined (so the
`SASSERT`
  is active): builds cleanly.

### What we did not verify

This is a debug-only (`SASSERT`) correctness fix and has no effect on
release
builds. No behavioral test was added.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: ad2c295d-7523-48cf-b786-b435b833e3af
2026-07-30 20:04:53 -07:00
..
dd Remove unused swap() methods (#8538) 2026-02-08 18:53:43 +00:00
grobner Fix reversed precondition assertion in grobner::pop_scope (#10318) 2026-07-30 20:04:53 -07:00
hilbert Centralize and document TRACE tags using X-macros (#7657) 2025-05-28 14:31:25 +01:00
interval nla: add LP-based nonlinear bound optimization for cross-nested confl… (#10180) 2026-07-23 09:00:46 -07:00
lp Imp fix (#10304) 2026-07-30 12:45:06 -07:00
polynomial Use macros to disable semi-colon warnings for blocks of macros. (#10192) 2026-07-22 18:01:50 -07:00
realclosure Use macros to disable semi-colon warnings for blocks of macros. (#10192) 2026-07-22 18:01:50 -07:00
simplex Remove unnecessary semicolons (Attempt 2) (#10020) 2026-07-02 12:47:29 -07:00
subpaving Remove unnecessary semicolons (Attempt 2) (#10020) 2026-07-02 12:47:29 -07:00