From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp41.i.mail.ru (smtp41.i.mail.ru [94.100.177.101]) (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 E812845C304 for ; Mon, 30 Nov 2020 15:47:49 +0300 (MSK) References: <6011a5182431783749d8f15604710d7d8111b602.1606479683.git.artemreyt@tarantool.org> From: Aleksandr Lyapunov Message-ID: <65c5e06d-56f0-d68e-c945-80854d8f17d8@tarantool.org> Date: Mon, 30 Nov 2020 15:47:48 +0300 MIME-Version: 1.0 In-Reply-To: <6011a5182431783749d8f15604710d7d8111b602.1606479683.git.artemreyt@tarantool.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Subject: Re: [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: Artem Starshov , Alexander Turenko Cc: tarantool-patches@dev.tarantool.org Hi! Thank for the patch! LGTM now. I'm glad we found such a laconic solution. On 11/27/20 3:43 PM, Artem Starshov wrote: > 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;