From cbaab30449fdeea90e1d97721f1bbc25681e5e35 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Mon, 17 Jul 2017 10:33:12 -0700 Subject: [PATCH] table/block.h: change memset MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: In gcc-7 the following is an error identified by -Werror=class-memaccess In file included from ./table/get_context.h:14:0, from db/version_set.cc:43: ./table/block.h: In constructor ‘rocksdb::BlockReadAmpBitmap::BlockReadAmpBitmap(size_t, size_t, rocksdb::Statistics*)’: ./table/block.h:73:53: error: ‘void* memset(void*, int, size_t)’ clearing an object of type ‘struct std::atomic’ with no trivial copy-assignment; use value-initialization instead [-Werror=class-memaccess] memset(bitmap_, 0, bitmap_size * kBytesPersEntry); ^ In file included from ./db/version_set.h:23:0, from db/version_set.cc:12: /toolchain/include/c++/8.0.0/atomic:684:12: note: ‘struct std::atomic’ declared here struct atomic : __atomic_base ^~~~~~~~~~~~~~~~~~~~ As a solution the default initializer can be applied in list context. Signed-off-by: Daniel Black Closes https://github.com/facebook/rocksdb/pull/2561 Differential Revision: D5398714 Pulled By: siying fbshipit-source-id: d883fb88ec7535eee60d551038fe91f14488be36 --- table/block.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/table/block.h b/table/block.h index 044e07662..59dc16743 100644 --- a/table/block.h +++ b/table/block.h @@ -67,8 +67,7 @@ class BlockReadAmpBitmap { size_t bitmap_size = (num_bits_needed - 1) / kBitsPerEntry + 1; // Create bitmap and set all the bits to 0 - bitmap_ = new std::atomic[bitmap_size]; - memset(bitmap_, 0, bitmap_size * kBytesPersEntry); + bitmap_ = new std::atomic[bitmap_size](); RecordTick(GetStatistics(), READ_AMP_TOTAL_READ_BYTES, block_size); }