buffer_va_index: use numeric_limits<Id>::max() in max_id() for signed Id types #2290
No reviewers
No assignees
Labels
No labels
bug
dependencies
documentation
enhancement
missing claim
needs rebase
needs-triage
question
ready-for-agent
submodules
No project
No milestone
Dependencies
No dependencies set
Notifications
1 participant
Due date
No due date set.
Reference
leonida/mandy!2290
Loading…
Reference in a new issue
No description provided.
Delete branch "ubiq-buffer-va-index-signed-max-id"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Pull request successfully merged and closed
Summary
(std::numeric_limits<Id>::max)()instead of~Id(0)inBufferVaIndex<Id>::max_id()(runtime/src/buffer_va_index.h).Idtypes (e.g.int),~Id(0)evaluates to-1, which causesranges_.upper_bound({va, max_id()})infind()to stop before all non-negative IDs atstart == vaand miss ranges starting at the queried VA.(std::numeric_limits<Id>::max)()works for both signed and unsigned integerIdtypes (parenthesised to avoid Windowsmaxmacro collisions).signed_id_cases()regression coverage toruntime/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.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://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7192490144)
AI-assisted: yes (Gemini)
Reviewed by Claude Code (AI-assisted) on my behalf. Approving.
~Id(0)is -1 for a signedId, somax_id()was the smallest id rather than the largest.numeric_limits<Id>::max()is the same value for the unsigned ids in use. Checked:buffer_va_index_testpasseswith
-fsanitize=address,undefined(g++ 13, Linux). Against main's header,signed_id_casesfails ("exact startpicks larger positive id"), so the test covers the change.
Generated by Claude Code
Verified on Windows 11 (
10.0.26200.9974) with MSVC19.44.35228(x64,/std:c++20 /EHsc /W4 /permissive- /utf-8 /O2) againstmaind48a957bb+31bd3bd641(claim#2570#issuecomment-7239117859):runtime/src/buffer_va_index.h,runtime/test/buffer_va_index_test.cpp); replaces~Id(0)with parenthesized(std::numeric_limits<Id>::max)()inBufferVaIndex::max_id()sostarts_.upper_bound({va, max_id()})works for signed integerIdinstantiations instead of comparing against-1.check_no_game_data.pyclean.d48a957bb+ PR test):buffer_va_index_test.exefails (rc=1,FAIL: signed Id: exact start picks larger positive id).d48a957bb+31bd3bd641merge): Auto-merges cleanly (rc=0), compiles with0warnings under/W4 /permissive-, and passes (BufferVaIndex: fixed cases and 200 random tables agree with the scan,rc=0).AI-assisted.
Red/green: On main buffer_va_index_test fails 1 check (with a signed Id an exact start picks the wrong id because max_id() returns -1), and with the PR ctest -R "^buffer_va_index$" passes.
Independent tester (OreoFR, RTX 4070, Windows 11): PR head merged with the other PRs of its batch on main c1ecf04ed, full ctest run (485 tests, tests that launch the game excluded): no new failure compared with main.
Verified by OreoFR
c1ecf04ed+ PR head31bd3bd64; green run in a merge package of 16 PRs, no new ctest failure vs mainctest -R "^buffer_va_index$"AI-assisted (Claude Code, Claude Opus 5.5).