diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2014-07-10 00:28:16 +0900 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2014-07-10 00:28:16 +0900 |
| commit | 897f0e87f4bd69bf6703a12feb326aeba53b0dcd (patch) | |
| tree | 0210af6357fdf24043fa2e608921cda6621c7e63 | |
| parent | 4dfd8b884775737f85783976958f4e976b65a5fb (diff) | |
MinGW: Fix compiler warning with -Wstrict-aliasing
The error message is:
warning: dereferencing type-punned pointer will break strict-aliasing
rules [-Wstrict-aliasing]
| -rw-r--r-- | src/crypto_hash.cc | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/src/crypto_hash.cc b/src/crypto_hash.cc index bff70316..43a7cc0c 100644 --- a/src/crypto_hash.cc +++ b/src/crypto_hash.cc @@ -167,14 +167,13 @@ public: } // Append length, multiplied by 8 (because bits!) - const uint_fast64_t bits = count_ << 3; + const uint_fast64_t bits = __crypto_be(count_ << 3); if (sizeof(word_t) == 4) { - *reinterpret_cast<uint64_t*>(buffer_.words + bsize - 2) = - __crypto_be(bits); + memcpy(buffer_.words + bsize - 2, &bits, sizeof(bits)); } else { buffer_.words[bsize - 2] = 0; - buffer_.words[bsize - 1] = (word_t)__crypto_be(bits); + buffer_.words[bsize - 1] = (word_t)bits; } // Last transform: @@ -340,9 +339,8 @@ public: } // Append length, multiplied by 8 (because bits!) - const uint_fast64_t bits = count_ << 3; - *reinterpret_cast<uint64_t*>(buffer_.words + 14) = - __crypto_le(bits); + const uint_fast64_t bits = __crypto_le(count_ << 3); + memcpy(buffer_.words + 14, &bits, sizeof(bits)); transform(buffer_.words); #if BIG_ENDIAN == BYTE_ORDER state_.words[0] = __crypto_bswap(state_.words[0]); |
