Repository navigation
[M2-SPRITE-02] MSVC fix: explicit size_t -> u32 cast in submit (C4267) - #72
Merged
Merged
Conversation
The merge-lane CI (run 37189830435) failed on the Windows x64
(MSVC 2022) job only: sprite_renderer.cpp(557) warning C4267
('initializing': conversion from 'size_t' to 'uint32_t', possible loss
of data) treated as an error under /WX. The PR lane labels Windows
gated (ci:windows), so MSVC had not compiled this step's code before
the merge.
Root cause: `const std::uint32_t n = batcher.frameCount();` —
SpriteBatcher::frameCount() returns std::size_t; on the 64-bit MSVC
toolchain the implicit narrowing is a C4267. The value is always <=
the batcher's u32 capacity (kSpriteBatcherMaxCapacity), so the
narrowing is lossless; the fix is the explicit static_cast (the house
style for the size_t -> u32 boundary, e.g. the instance pack above it).
Full audit of the step's new MSVC-unverified files (sprite_renderer.h,
sprite_renderer.cpp, sprite_draw_tests.cpp, the gl_context.h/.cpp
frameBuffer additions): no other implicit narrowing remains (every
other size_t source is an explicit static_cast or a comparison).
Local verification: canonical tree rebuilds warning-free; ctest -R
sprite_draw green. Windows verification: the ci:windows label is
applied to this PR so the MSVC job runs on the PR lane before merge.
Owner
Author
CI status
|
The branch's first CI run (37192995927) was created before the ci:windows label was applied, so its label context is stale — a rerun reuses the original event and the windows-msvc job stays skipped. This empty commit fires a fresh pull_request event with the current labels so the Windows x64 (MSVC 2022) job (the one this fix targets) runs on the PR lane before merge. No code change.
Owner
Author
CI resolved
All P0 lanes are now green on this branch — ready for merge. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
The M2-SPRITE-02 merge (commit
08e96d3) failed the merge-lane CI on the Windows x64 (MSVC 2022) job only — run 37189830435:The PR lane runs Windows only under the
ci:windowslabel, so MSVC had not compiled this step's code before the merge.Root cause
const std::uint32_t n = batcher.frameCount();—SpriteBatcher::frameCount()returnsstd::size_t; on the 64-bit MSVC toolchain the implicit narrowing is C4267, and the job builds with warnings-as-errors.Fix
One explicit
static_cast<std::uint32_t>(the house style for the size_t → u32 boundary — the same cast the instance pack uses two lines below). Lossless by invariant: the frame count is always ≤ the batcher's u32 capacity (kSpriteBatcherMaxCapacity), so no value is ever truncated.Audit of the rest of the step's MSVC-unverified code
sprite_renderer.h,sprite_renderer.cpp,sprite_draw_tests.cpp, and theGlContext::frameBuffer()additions were scanned for every implicit narrowing (every.size()/frameCount()/GL-size source): no other C4267/C4244 trigger remains — everything else is already an explicitstatic_castor a comparison.Verification
ctest -R sprite_drawgreen (12/12).ci:windowslabel is applied to this PR so the MSVC 2022 job runs on the PR lane before merge.laige-api.jsonunaffected (no signature change).