[clang] [Clang] Fix offsetof sign-extending unsigned array indices >= 128 (PR #204139)
Marlus Cadanus da Costa via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 25 06:57:07 PDT 2026
================
@@ -0,0 +1,50 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -triple x86_64-linux-gnu
+// RUN: %clang_cc1 -fsyntax-only -verify %s -triple x86_64-linux-gnu -fexperimental-new-constant-interpreter
+
+// Test that offsetof correctly zero-extends unsigned array indices >= 128.
+// Previously, Clang would sign-extend uint8_t indices >= 128, producing
+// a large bogus offset value instead of the correct one.
+// Also tests that negative indices and oversized __uint128_t indices are rejected.
+// https://github.com/llvm/llvm-project/issues/199319
+
+#include <stdint.h>
+#include <stddef.h>
----------------
marlus wrote:
Done. Replaced #include <stdint.h> and #include <stddef.h> with manual typedefs
https://github.com/llvm/llvm-project/pull/204139
More information about the cfe-commits
mailing list