================ @@ -230,8 +230,13 @@ void DwarfFDECache<A>::iterateCacheEntries(void (*func)( } #endif // defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND) - -#define arrayoffsetof(type, index, field) ((size_t)(&((type *)0)[index].field)) +template <typename TYPE, typename FIELD> +__attribute__((no_sanitize("undefined"))) static inline size_t +_arrayoffsetof(int index, FIELD TYPE::*field) { + return ((size_t)(&(((TYPE *)0)[index].*field))); +} +#define arrayoffsetof(type, index, field) \ + _arrayoffsetof<struct type>(index, &type::field) ---------------- nikic wrote:
You can replace this with something like `sizeof(type) * index + offsetof(type, field)`, which is safe. https://github.com/llvm/llvm-project/pull/98648 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits