Bug 405182

Summary: Valgrind fails to build with Clang
Product: [Developer tools] valgrind Reporter: Ed Maste <emaste>
Component: generalAssignee: Julian Seward <jseward>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version First Reported In: unspecified   
Target Milestone: ---   
Platform: Other   
OS: FreeBSD   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: cast patch to fix Clang failure

Description Ed Maste 2019-03-07 16:30:54 UTC
Created attachment 118631 [details]
cast patch to fix Clang failure

SUMMARY
Clang/LLVM fails an assertion when compiling my_offsetof in VEX/auxprogs/genoffsets.c.

STEPS TO REPRODUCE
1. Build Valgrind with Clang (tested on FreeBSD with Clang 8.0)

OBSERVED RESULT
Clang assertion failure:
Assertion failed: (EVResult.Val.isInt() && "Expression did not evaluate to integer"), function EvaluateKnownConstInt, file /home/dim/src/llvm/trunk/tools/clang/lib/AST/ExprConstant.cpp, line 11056.

EXPECTED RESULT
Valgrind builds

The assertion failure is a Clang bug, but the fix is probably to emit a diagnostic message instead. Details in https://bugs.llvm.org/show_bug.cgi?id=40890. Attached patch copies cast from the other my_offsetof definition (from none/tests/x86/x87trigOOR.c).

SOFTWARE/OS VERSIONS
FreeBSD 12.0

ADDITIONAL INFORMATION
Comment 1 Ed Maste 2019-03-07 20:15:35 UTC
This has been patched in Clang upstream and in FreeBSD's copy (https://svnweb.freebsd.org/changeset/base/344896), but having two different my_offsetof macros is still worth cleaning up.
Comment 2 Julian Seward 2019-03-12 17:40:35 UTC
Pushed as 4816357b5c7ee5284cdf72800a81d2dd1845388f.  Thanks
for the patch and diagnosis.