buffer_va_index: use numeric_limits<Id>::max() in max_id() for signed Id types #2290

Open
github-bot wants to merge 1 commit from github-bot/gh-2290 into main AGit
Owner

@⁠narekshaghoyandev on GitHub · 2026-11-26 12:50 UTC · original
narekshaghoyandev:ubiq-buffer-va-index-signed-max-id → main · +14 −1 · 2 files · 1 commits · open

Summary

  • Use (std::numeric_limits<Id>::max)() instead of ~Id(0) in BufferVaIndex<Id>::max_id() (runtime/src/buffer_va_index.h).
    • For signed Id types (e.g. int), ~Id(0) evaluates to -1, which causes ranges_.upper_bound({va, max_id()}) in find() to stop before all non-negative IDs at start == va and miss ranges starting at the queried VA.
    • (std::numeric_limits<Id>::max)() works for both signed and unsigned integer Id types (parenthesised to avoid Windows max macro collisions).
  • Add signed_id_cases() regression coverage to runtime/test/buffer_va_index_test.cpp.

Verification

  • g++ -std=c++20 -D_GLIBCXX_DEBUG -Wall -Wextra -Werror -Wno-mismatched-new-delete -pedantic -O2 -g runtime/test/buffer_va_index_test.cpp — pass (fixed cases, signed ID cases, 200 random tables).
  • g++ -std=c++20 -Wall -Wextra -Werror -Wno-mismatched-new-delete -pedantic -fsanitize=undefined -O2 -g runtime/test/buffer_va_index_test.cpp — pass.
  • Negative control against main: fails (FAIL: signed Id: exact start picks larger positive id, exit 1) before the patch and passes after.
  • python3 -I scripts/check_no_game_data.py runtime/src/buffer_va_index.h runtime/test/buffer_va_index_test.cpp — clean.

Claimed in the coordination issue as: RT-BUFFER-VA-INDEX-SIGNED-MAX-ID (#1608)
AI-assisted: yes (Gemini)

**@⁠narekshaghoyandev** on GitHub · 2026-11-26 12:50 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2290) `narekshaghoyandev:ubiq-buffer-va-index-signed-max-id` → `main` · +14 −1 · 2 files · 1 commits · open ## Summary - Use `(std::numeric_limits<Id>::max)()` instead of `~Id(0)` in `BufferVaIndex<Id>::max_id()` (`runtime/src/buffer_va_index.h`). - For signed `Id` types (e.g. `int`), `~Id(0)` evaluates to `-1`, which causes `ranges_.upper_bound({va, max_id()})` in `find()` to stop before all non-negative IDs at `start == va` and miss ranges starting at the queried VA. - `(std::numeric_limits<Id>::max)()` works for both signed and unsigned integer `Id` types (parenthesised to avoid Windows `max` macro collisions). - Add `signed_id_cases()` regression coverage to `runtime/test/buffer_va_index_test.cpp`. ## Verification - `g++ -std=c++20 -D_GLIBCXX_DEBUG -Wall -Wextra -Werror -Wno-mismatched-new-delete -pedantic -O2 -g runtime/test/buffer_va_index_test.cpp` — pass (fixed cases, signed ID cases, 200 random tables). - `g++ -std=c++20 -Wall -Wextra -Werror -Wno-mismatched-new-delete -pedantic -fsanitize=undefined -O2 -g runtime/test/buffer_va_index_test.cpp` — pass. - Negative control against `main`: fails (`FAIL: signed Id: exact start picks larger positive id`, exit 1) before the patch and passes after. - `python3 -I scripts/check_no_game_data.py runtime/src/buffer_va_index.h runtime/test/buffer_va_index_test.cpp` — clean. Claimed in the coordination issue as: RT-BUFFER-VA-INDEX-SIGNED-MAX-ID (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/1608) AI-assisted: yes (Gemini)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 12:52:31 +00:00
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2290/head:github-bot/gh-2290'
git switch 'github-bot/gh-2290'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2290'
git switch 'github-bot/gh-2290'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2290'
git switch 'github-bot/gh-2290'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2290'
git switch 'main'
git merge --squash 'github-bot/gh-2290'
git switch 'main'
git merge --ff-only 'github-bot/gh-2290'
git switch 'main'
git merge 'github-bot/gh-2290'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.