[llvm] [gsymutil] Fix a warning on systems with 32-bit `off_t` (PR #189524)
Justin Bogner via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 30 20:19:23 PDT 2026
https://github.com/bogner created https://github.com/llvm/llvm-project/pull/189524
The size of `off_t` isn't specified, so it can be either 32 or 64 bits depending on the system. In particular, on LLP64 systems like windows it's generally only 32 bits. This means the `if (StrtabSize > UINT32_MAX)` check added in #181458 may warn on such systems (Giving -Wsign-compare).
Given that `FileWriter::tell` doesn't even return `off_t`, but `uint64_t`, the simplest fix is to just use the return type of the function instead of potentially truncating.
>From bc073caac6662b3b2396fb02362b70fca8c2a062 Mon Sep 17 00:00:00 2001
From: Justin Bogner <mail at justinbogner.com>
Date: Mon, 30 Mar 2026 19:44:33 -0700
Subject: [PATCH] [gsymutil] Fix a warning on systems with 32-bit `off_t`
The size of `off_t` isn't specified, so it can be either 32 or 64 bits
depending on the system. In particular, on LLP64 systems like windows it's
generally only 32 bits. This means the `if (StrtabSize > UINT32_MAX)` check
added in #181458 may warn on such systems (Giving -Wsign-compare).
Given that `FileWriter::tell` doesn't even return `off_t`, but `uint64_t`, the
simplest fix is to just use the return type of the function instead of
potentially truncating.
---
llvm/lib/DebugInfo/GSYM/GsymCreator.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/llvm/lib/DebugInfo/GSYM/GsymCreator.cpp b/llvm/lib/DebugInfo/GSYM/GsymCreator.cpp
index f26e69fda2540..b4f7a52b2e95e 100644
--- a/llvm/lib/DebugInfo/GSYM/GsymCreator.cpp
+++ b/llvm/lib/DebugInfo/GSYM/GsymCreator.cpp
@@ -164,9 +164,9 @@ llvm::Error GsymCreator::encode(FileWriter &O) const {
}
// Write out the string table.
- const off_t StrtabOffset = O.tell();
+ const uint64_t StrtabOffset = O.tell();
StrTab.write(O.get_stream());
- const off_t StrtabSize = O.tell() - StrtabOffset;
+ const uint64_t StrtabSize = O.tell() - StrtabOffset;
std::vector<uint32_t> AddrInfoOffsets;
// Verify that the size of the string table does not exceed 32-bit max.
More information about the llvm-commits
mailing list