Fix md5 problem with freebsd 11.0 clang 3.8

With clang on FreeBSD 11.0-p1, some md5 functions tend to return the
wrong result. This is, e.g., visible when running the bifs/md5 testcase.
In this test, the checks using md5_hash_finish will return an empty
string.

The apparent cause is some confusion in clang when using a static char
inside a static inline function that is refered to several compilation
units.

Exact version of clang showing this issue is:
FreeBSD clang version 3.8.0 (tags/RELEASE_380/final 262564) (based on LLVM 3.8.0)
Target: x86_64-unknown-freebsd11.0
Thread model: posix
InstalledDir: /usr/bin

Issue occurs with -O2.

The first person to either find an existing clang bugreport for this, or
to create an minimal testcase and files one will get a drink from me :)
This commit is contained in:
Johanna Amann 2016-10-13 13:26:43 -07:00
parent 14fd08f334
commit f135a63c61

View file

@ -12,7 +12,7 @@
#include "Reporter.h"
static inline const char* digest_print(const u_char* digest, size_t n)
inline const char* digest_print(const u_char* digest, size_t n)
{
static char buf[256]; // big enough for any of md5/sha1/sha256
for ( size_t i = 0; i < n; ++i )