[clang] [Clang] Fix offsetof sign-extending unsigned array indices >= 128 (PR #204139)
Timm Baeder via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 23 21:32:24 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>
----------------
tbaederr wrote:
You shouldn't have any standard includes in test in general, add the typedefs manually.
https://github.com/llvm/llvm-project/pull/204139
More information about the cfe-commits
mailing list