From 2b356118b6af062ba794541076e7ae5e0a3e3c26 Mon Sep 17 00:00:00 2001 From: Tudor Bosman Date: Mon, 26 Aug 2013 21:39:36 -0700 Subject: [PATCH] Expand the range where uninitialized warnings are ignored Summary: gcc 4.8 is picky Test Plan: folly tests, compiled unicorn with gcc 4.8 Reviewed By: andrei.alexandrescu@fb.com FB internal diff: D945336 --- folly/experimental/Bits.h | 41 +++++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/folly/experimental/Bits.h b/folly/experimental/Bits.h index df23d859..5983988d 100644 --- a/folly/experimental/Bits.h +++ b/folly/experimental/Bits.h @@ -52,6 +52,7 @@ struct BitsTraits, typename std::enable_if< static T loadRMW(const Unaligned& x) { #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wuninitialized" +#pragma GCC diagnostic ignored "-Wmaybe-uninitialized" return x.value; #pragma GCC diagnostic pop } @@ -67,6 +68,7 @@ struct BitsTraits inline void Bits::set(T* p, size_t bit) { T& block = p[blockIndex(bit)]; @@ -176,11 +185,6 @@ inline void Bits::clear(T* p, size_t bit) { Traits::store(block, Traits::loadRMW(block) & ~(one << bitOffset(bit))); } -template -inline bool Bits::test(const T* p, size_t bit) { - return Traits::load(p[blockIndex(bit)]) & (one << bitOffset(bit)); -} - template inline void Bits::set(T* p, size_t bitStart, size_t count, UnderlyingType value) { @@ -198,6 +202,23 @@ inline void Bits::set(T* p, size_t bitStart, size_t count, } } +template +inline void Bits::innerSet(T* p, size_t offset, size_t count, + UnderlyingType value) { + // Mask out bits and set new value + UnderlyingType v = Traits::loadRMW(*p); + v &= ~(ones(count) << offset); + v |= (value << offset); + Traits::store(*p, v); +} + +#pragma GCC diagnostic pop + +template +inline bool Bits::test(const T* p, size_t bit) { + return Traits::load(p[blockIndex(bit)]) & (one << bitOffset(bit)); +} + template inline auto Bits::get(const T* p, size_t bitStart, size_t count) -> UnderlyingType { @@ -215,16 +236,6 @@ inline auto Bits::get(const T* p, size_t bitStart, size_t count) } } -template -inline void Bits::innerSet(T* p, size_t offset, size_t count, - UnderlyingType value) { - // Mask out bits and set new value - UnderlyingType v = Traits::loadRMW(*p); - v &= ~(ones(count) << offset); - v |= (value << offset); - Traits::store(*p, v); -} - template inline auto Bits::innerGet(const T* p, size_t offset, size_t count) -> UnderlyingType { -- 2.34.1