From: Julian Seward Date: Tue, 12 Mar 2019 17:37:15 +0000 (+0100) Subject: VEX/auxprogs/genoffsets.c: Add cast to my_offsetof. n-i-bz. X-Git-Tag: VALGRIND_3_15_0~58 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4816357b5c7ee5284cdf72800a81d2dd1845388f;p=thirdparty%2Fvalgrind.git VEX/auxprogs/genoffsets.c: Add cast to my_offsetof. n-i-bz. Clang/LLVM trips over my_offsetof in VEX/auxprogs/genoffsets.c. See LLVM PR 40890 for details (https://bugs.llvm.org/show_bug.cgi?id=40890). Now, it's a Clang bug that Clang exits on an assertion failure rather than emits a diagnostic, but the previous my_offsetof expression is a pointer, not an integer. Add a cast as done in other definitions of offsetof in the tree. Patch from Ed Maste . --- diff --git a/VEX/auxprogs/genoffsets.c b/VEX/auxprogs/genoffsets.c index 1f680e4f6c..aa326b35ef 100644 --- a/VEX/auxprogs/genoffsets.c +++ b/VEX/auxprogs/genoffsets.c @@ -59,7 +59,8 @@ #define VG_STRINGIFZ(__str) #__str #define VG_STRINGIFY(__str) VG_STRINGIFZ(__str) -#define my_offsetof(__type,__field) (&((__type*)0)->__field) +#define my_offsetof(__type,__field) \ + ((unsigned long int)(&((__type*)0)->__field)) /* This forces gcc to evaluate the my_offsetof call at compile time, and then emits it in the assembly, along with the nonsense string