[Lldb-commits] [lldb] [lldb] Add static_assert to catch increases to size of Symbol (PR #200919)

Martin Storsjö via lldb-commits lldb-commits at lists.llvm.org
Tue Jun 2 02:16:46 PDT 2026


mstorsjo wrote:

This static assert fails on 32 bit Windows: https://github.com/mstorsjo/llvm-mingw/actions/runs/26795477370/job/79006149129

It seems like the class ends up with size 56 rather than 52 on 32 bit Windows (while it does match the expected 80 bytes on 64 bit Windows). Both mingw style builds, with Itanium C++ ABI, and MSVC C++ ABI, seem to end up at the same 56 bytes for this class. I haven't looked closely at why this happens. The main difference usually is in how bitfields are packed, but the one case of bitfield here seems like it should behave the same as on unix.

We can go with a fix like this:
```diff
diff --git a/lldb/include/lldb/Symbol/Symbol.h b/lldb/include/lldb/Symbol/Symbol.h
index 2f232346a282..92100d9a68e5 100644
--- a/lldb/include/lldb/Symbol/Symbol.h
+++ b/lldb/include/lldb/Symbol/Symbol.h
@@ -365,10 +365,17 @@ static_assert(
     sizeof(lldb_private::Symbol) == 80,
     "Symbol is a high volume data type, size must be increased with care");
 #elif __SIZEOF_POINTER__ == 4
+#ifdef _WIN32
+static_assert(
+    sizeof(lldb_private::Symbol) == 56,
+    "Symbol is a high volume data type, size must be increased with care");
+#endif
+#else
 static_assert(
     sizeof(lldb_private::Symbol) == 52,
     "Symbol is a high volume data type, size must be increased with care");
 #endif
+#endif
 
 namespace llvm {
 namespace json {
```
Or we could just do a `#elif __SIZEOF_POINTER__ == 4 && !defined(_WIN32)` and simply not bother with tracking the size specifically on 32 bit Windows (as few probably care about that these days) - the static asserts for other platforms probably are enough for keeping track of not accidentally inflating the class anyway.

https://github.com/llvm/llvm-project/pull/200919


More information about the lldb-commits mailing list