From 584dfc768850917ee0c1c72075640788c4fb24fc Mon Sep 17 00:00:00 2001 From: Yi Kong Date: Thu, 11 May 2017 11:51:08 -0700 Subject: [PATCH] Do not use default initializer for union The next Clang update complains about this code pattern. Rewrite default constructor to explicitly initialize the union field instead of using the default initializer. Test: Build Bug: 37752547 Change-Id: I22a2aa392d7f4803282baed832b0fa2f852016ac (cherry picked from commit 4fdbdd1692a549a31382f33f5d529fd141453ea1) --- libs/math/include/math/half.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libs/math/include/math/half.h b/libs/math/include/math/half.h index 615b840b01..76829734a4 100644 --- a/libs/math/include/math/half.h +++ b/libs/math/include/math/half.h @@ -56,8 +56,8 @@ namespace android { */ class half { struct fp16 { - uint16_t bits = 0; - fp16() noexcept = default; + uint16_t bits; + explicit constexpr fp16() noexcept : bits(0) { } explicit constexpr fp16(uint16_t b) noexcept : bits(b) { } void setS(unsigned int s) noexcept { bits = uint16_t((bits & 0x7FFF) | (s<<15)); } void setE(unsigned int s) noexcept { bits = uint16_t((bits & 0xE3FF) | (s<<10)); } @@ -68,11 +68,11 @@ class half { }; struct fp32 { union { - uint32_t bits = 0; + uint32_t bits; float fp; }; - fp32() noexcept = default; - explicit constexpr fp32(float f) : fp(f) { } + explicit constexpr fp32() noexcept : bits(0) { } + explicit constexpr fp32(float f) noexcept : fp(f) { } void setS(unsigned int s) noexcept { bits = uint32_t((bits & 0x7FFFFFFF) | (s<<31)); } void setE(unsigned int s) noexcept { bits = uint32_t((bits & 0x807FFFFF) | (s<<23)); } void setM(unsigned int s) noexcept { bits = uint32_t((bits & 0xFF800000) | (s<< 0)); } -- 2.11.0