From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp3.mail.ru (smtp3.mail.ru [94.100.179.58]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id D50BB45C305 for ; Fri, 27 Nov 2020 15:43:17 +0300 (MSK) From: Artem Starshov Date: Fri, 27 Nov 2020 15:43:10 +0300 Message-Id: <6011a5182431783749d8f15604710d7d8111b602.1606479683.git.artemreyt@tarantool.org> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH v2 2/2] bitset: replace zero-length array with flexible-array member List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alexander Turenko Cc: tarantool-patches@dev.tarantool.org Zero-lenght arrays are GNU C extension. There's ISO C99 flexible array member, which is preffered mechanism to declare variable-length types. Flexible array member allows us to avoid applying sizeof operator cause it's incomplete type, so it will be an error at compile time. There're any moments else why it's better way to implement such structures via FAM: https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html In this issue it fixed gcc 10 warning: "warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]" Closes #4966 Closes #5564 --- src/lib/bitset/bitset.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/bitset/bitset.h b/src/lib/bitset/bitset.h index e2ae4f5f6..775de5c07 100644 --- a/src/lib/bitset/bitset.h +++ b/src/lib/bitset/bitset.h @@ -69,7 +69,7 @@ struct tt_bitset_page { size_t first_pos; rb_node(struct tt_bitset_page) node; size_t cardinality; - uint8_t data[0]; + uint8_t data[]; }; typedef rb_tree(struct tt_bitset_page) tt_bitset_pages_t; -- 2.28.0