From 1fe6d564523982d2efbd28334ef50fe449765eb5 Mon Sep 17 00:00:00 2001 From: Justin Bogner Date: Tue, 2 Jun 2026 13:49:06 -0700 Subject: [PATCH] Fix a warning and an uninitialized variable in benchmark (#200927) After #198964 I see a -Wcovered-switch-default warning in sysinfo.cc, but it looks like it's uncovering something a bit worse. Back in #147357 and #149159 it looks like we tried to fix an MSVC warning for an uncovered `CacheUnknown` case in this switch, and removed the initialization of the variable before the switch. The update to Google Benchmark v1.9.5 has a different fix for this - it's handling that specific case guarded by some MSVC version macros, but this depends on the initialization we removed! Add the initialization back and remove the default case, effectively reverting #149159 and #147357. --- third-party/benchmark/src/sysinfo.cc | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/third-party/benchmark/src/sysinfo.cc b/third-party/benchmark/src/sysinfo.cc index d25888548fe8..3977772bfede 100644 --- a/third-party/benchmark/src/sysinfo.cc +++ b/third-party/benchmark/src/sysinfo.cc @@ -370,6 +370,7 @@ std::vector GetCacheSizesWindows() { C.num_sharing = static_cast(b.count()); C.level = cache.Level; C.size = static_cast(cache.Size); + C.type = "Unknown"; switch (cache.Type) { // Windows SDK version >= 10.0.26100.0 #ifdef NTDDI_WIN11_GE @@ -388,9 +389,6 @@ std::vector GetCacheSizesWindows() { case CacheTrace: C.type = "Trace"; break; - default: - C.type = "Unknown"; - break; } res.push_back(C); }