From 7b132280cc199f815df42a7dc23d654307ab6b40 Mon Sep 17 00:00:00 2001 From: Ettore Di Giacinto Date: Fri, 14 Aug 2026 16:40:04 +0000 Subject: [PATCH] fix(#757): six C4456 shadowed locals block the Windows test compile FOLLOWING_AGENTS_PROTOCOL `windows-msvc-vulkan` fails compiling a TEST target with test_backend_cross_device.cpp(514,20): warning C4456: declaration of 'cpu' hides previous local declaration test_backend_cross_device.cpp(514,20): error C2220: warning treated as error and five more on the same block. The inner "Unbind flash layout" scope re-declares SIX names the enclosing scope already owns -- `cpu` `cq` `cd` `ck` `cv` `cslots` at :514-518, hiding :451-455. Renamed with an `f` prefix, after the block's own comment. Nothing else moved. Not from the LTX-2.5 lane: the line is from 822b3a2e15 (2026-08-07). It was simply UNREACHABLE until the library compiled. #664 (f8cbc2310) and #720 (0011bedf0) landed today and the Windows lane now gets past the library into the test targets for the first time, which is what exposed it. THE INSTRUMENT, because my first one under-reported. A hand-written Python scope-sweep found FIVE shadow pairs where MSVC found six -- it could not see `cv`, the SECOND declarator on line 517. A lower bound presented as a count. So the check is `g++ -Wshadow`, which reproduces MSVC's C4456 at the same lines AND columns, with a positive control on the pre-fix file: PRE-FIX :514:20 cpu :515:13 cq :516:20 cd :517:26 ck :517:37 cv :518:28 cslots -> 6 POST-FIX -> 0 That column-exact match is what makes a Linux proxy usable for an MSVC-only diagnostic; it is the same technique that validated the #720 `M_PI` fix. PURE RENAMING, proved rather than asserted: mapping the new names back reproduces the pre-fix file byte-for-byte, token counts are equal at 28466, and exactly 18 tokens differ -- all of them the renames. `BUILD_EXIT=0`, 0 errors, 0 ENOSPC; `test_backend_cross_device` 19 cases / 3 assertions, exit 0 (the device loops are empty on a CPU-only build, so the count is small by construction rather than by regression). Why the class was invisible on Linux: `-Wshadow` is not enabled for the CPU or Vulkan builds, while MSVC's /W4 /WX makes C4456 an error. Nothing ever emitted it. Enabling it locally is a separate decision and is NOT taken here. Closes #757. Following-Agents-Protocol: true AI-Assisted: true Assisted-by: AGENT:claude-opus-5[1m] [claude-code] --- tests/vt/test_backend_cross_device.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/vt/test_backend_cross_device.cpp b/tests/vt/test_backend_cross_device.cpp index 186500e77..cd3820c63 100644 --- a/tests/vt/test_backend_cross_device.cpp +++ b/tests/vt/test_backend_cross_device.cpp @@ -511,15 +511,15 @@ TEST_CASE("ReshapeAndCache scatters into the KV cache BIT-EXACTLY") { } std::vector ref_comb = combined; { - vt::Backend& cpu = vt::GetBackend(DeviceType::kCPU); - Queue cq = cpu.CreateQueue(); - const Device cd{DeviceType::kCPU, 0}; - std::vector ck = knew, cv = vnew, cslots_f; - std::vector cslots = slots; - Tensor tk = Tensor::Contiguous(ck.data(), DType::kF32, cd, {kTokens, kHk, kD}); - Tensor tv = Tensor::Contiguous(cv.data(), DType::kF32, cd, {kTokens, kHk, kD}); + vt::Backend& fcpu = vt::GetBackend(DeviceType::kCPU); + Queue fq = fcpu.CreateQueue(); + const Device fd{DeviceType::kCPU, 0}; + std::vector fk = knew, fv = vnew, fslots_f; + std::vector fslots = slots; + Tensor tk = Tensor::Contiguous(fk.data(), DType::kF32, fd, {kTokens, kHk, kD}); + Tensor tv = Tensor::Contiguous(fv.data(), DType::kF32, fd, {kTokens, kHk, kD}); Tensor tcomb = - Tensor::Contiguous(ref_comb.data(), DType::kF32, cd, {kBlocks * 2 * within}); + Tensor::Contiguous(ref_comb.data(), DType::kF32, fd, {kBlocks * 2 * within}); auto slice = [&](int which) { Tensor t = tcomb; t.data = static_cast(t.data) + @@ -535,10 +535,10 @@ TEST_CASE("ReshapeAndCache scatters into the KV cache BIT-EXACTLY") { t.stride[3] = 1; return t; }; - Tensor tsm = Tensor::Contiguous(cslots.data(), DType::kI64, cd, {kTokens}); + Tensor tsm = Tensor::Contiguous(fslots.data(), DType::kI64, fd, {kTokens}); Tensor tkc = slice(0), tvc = slice(1); - vt::ReshapeAndCache(cq, tk, tv, tkc, tvc, tsm); - cpu.DestroyQueue(cq); + vt::ReshapeAndCache(fq, tk, tv, tkc, tvc, tsm); + fcpu.DestroyQueue(fq); } for (DeviceType dt : RegisteredDevices()) {