Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: Rewrite code to circument potential bug in clang
clang 7 to 11 (and maybe earlier versions) warn about recid being potentially unitiliazed in "CHECK(recid >= 0 [...]", which was mitigated in commit 3d2cf6c by initializing recid to make clang happy but VG_UNDEF'ing the variable after initializiation in order to ensure valgrind's memcheck analysis will still be sound and complain if recid is not actually written to when creating a signature. However, it turns out that at least for binaries produced by clang 11 (but not clang 7), valgrind complains about a branch on unitialized data in the recid variable in that line before *and* after the aforementioned commit. While the complaint after the commit could be spurious (clang knows that recid is initialized, so it's fine to access it even though the access is stupid), the complaint before the commit indicates a real problem: it might be the case that clang is performing a wrong optimization that leads to a situation where recid is really not guaranteed to be initialized when it's accessed. As a result, clang warns about this and generates code that just accesses the variable. I'm not going to bother with this further because this is fixed in clang 12 and the problem is just in our test code, not in the tested code. This commit rewrites the code in a way that groups the signing together with the CHECK such that it's very easy to figure out for clang that recid will be initialized properly. This seems to circument the issue.
- Loading branch information