diff options
author | Mike Klein <mtklein@chromium.org> | 2016-09-29 11:15:15 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2016-09-29 15:48:04 +0000 |
commit | 1e114f136895a41397483f4454cf6ce0af1206cd (patch) | |
tree | 7881aaac86c306d86232cbdf8ef2e5946451a2e5 /include | |
parent | 919f21f877a42b8c50531bcf813d7a1bc212f13c (diff) |
*SkTCast<int*>(float*) -> memcpy
In some build configurations (I think, GN, GCC 6, Debug) I get a warning that i is used unintialized. This likely has something to do with GCC correctly seeing that the SkTCast construction there is illegal aliasing, and perhaps thus "doesn't happen". Might be that if the SkTCast gets inlined, it decides its implementation is secretly kosher, and so Release builds don't see this. None of this happens with the GCCs we have on the bots... too old?
Instead use memcpy() here, which is well defined to do what we intended.
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2758
Change-Id: Iaf5c75fbd852193b0b861bf5e71450502511d102
Reviewed-on: https://skia-review.googlesource.com/2758
Commit-Queue: Ben Wagner <bungeman@google.com>
Reviewed-by: Ben Wagner <bungeman@google.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/private/SkFloatingPoint.h | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/include/private/SkFloatingPoint.h b/include/private/SkFloatingPoint.h index 8d8843eb58..6a6edf3651 100644 --- a/include/private/SkFloatingPoint.h +++ b/include/private/SkFloatingPoint.h @@ -107,9 +107,11 @@ static const uint32_t kIEEENotANumber = 0x7fffffff; static inline float sk_float_rsqrt_portable(float x) { // Get initial estimate. - int i = *SkTCast<int*>(&x); + int i; + memcpy(&i, &x, 4); i = 0x5F1FFFF9 - (i>>1); - float estimate = *SkTCast<float*>(&i); + float estimate; + memcpy(&estimate, &i, 4); // One step of Newton's method to refine. const float estimate_sq = estimate*estimate; |