Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4fdbdd16 authored by Yi Kong's avatar Yi Kong
Browse files

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
parent 6eef03e1
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -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)); }