From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lndn.lancelotsix.com (lndn.lancelotsix.com [51.195.220.111]) by sourceware.org (Postfix) with ESMTPS id 07B163858404 for ; Tue, 9 Nov 2021 21:58:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 07B163858404 Received: from ubuntu.lan (unknown [IPv6:2a02:390:9086::635]) by lndn.lancelotsix.com (Postfix) with ESMTPSA id 01F7C80D5C; Tue, 9 Nov 2021 21:58:52 +0000 (UTC) Date: Tue, 9 Nov 2021 21:58:48 +0000 From: Lancelot SIX To: Pedro Alves Cc: gdb-patches@sourceware.org Subject: Re: [PATCH] gdb::array_view slicing/container selftest - test std::array too (Re: [PATCH v2 2/2] Improve gdb::array_view ctor from contiguous containers) Message-ID: <20211109215848.h3caszzxf4lztjq7@ubuntu.lan> References: <8acafb4f-ef32-2de8-e71f-8243386b8159@palves.net> <20211103222015.50988-1-lsix@lancelotsix.com> <20211108230217.sejrgqlvs4ju2c2c@ubuntu.lan> <7300bb4f-c171-8646-41ec-3753a77cad4b@palves.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <7300bb4f-c171-8646-41ec-3753a77cad4b@palves.net> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.5.11 (lndn.lancelotsix.com [0.0.0.0]); Tue, 09 Nov 2021 21:58:53 +0000 (UTC) X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Nov 2021 21:58:56 -0000 On Tue, Nov 09, 2021 at 05:52:20PM +0000, Pedro Alves wrote: > On 2021-11-08 23:02, Lancelot SIX via Gdb-patches wrote: > >> Alternatively, you could mirror the comment from the built-in array tests: > >> > >> /* Check that there's no container->view conversion for containers of derived > >> types or subclasses. */ > >> > >> > >> In any case, this is OK. Thanks for fixing this! > > > > Hi, > > > > I just pushed this. > > Thanks. Looking again, I noticed we don't exercise construction from std::array containers, > unlike other tests. This adds it. WDYT? Hi, Actually my first version used a fixed size std::array exactly as you have here. I went for a std::vector instead in the version I have submitted to the list so I still test against one of the standard containers while not having to define StdArray1. I am absolutely fine including a test with a std::array. It could even replace the std::vector based test since this test is the only one that uses this container (in which case the '#include ' line could also be dropped). In the end, both options check that the old erroneous behavior that used to allow slicing now fails to compile. This is the most important point. Best, Lancelot. > > From 5da7a3deab00d81df9c5fa708520fc05d6a22ffa Mon Sep 17 00:00:00 2001 > From: Pedro Alves > Date: Tue, 9 Nov 2021 17:48:50 +0000 > Subject: [PATCH] gdb::array_view slicing/container selftest - test std::array > too > > Change-Id: I2141b0b8a09f6521a59908599eb5ba1a19b18dc6 > --- > gdb/unittests/array-view-selftests.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/gdb/unittests/array-view-selftests.c b/gdb/unittests/array-view-selftests.c > index 43b7434d10f..fe211a647b5 100644 > --- a/gdb/unittests/array-view-selftests.c > +++ b/gdb/unittests/array-view-selftests.c > @@ -137,8 +137,13 @@ check_ctor_from_container () > > } /* namespace no_slicing */ > > +/* std::array with only one template argument, so we can pass it to > + check_ctor_from_container. */ > +template using StdArray1 = std::array; > + > static_assert (no_slicing::check (), ""); > static_assert (no_slicing::check_ctor_from_container (), ""); > +static_assert (no_slicing::check_ctor_from_container (), ""); > static_assert (no_slicing::check_ctor_from_container (), ""); > > /* Check that array_view implicitly converts from std::vector. */ > > base-commit: f0bbba7886f5dba158a143bebbd0691591f22b9f > -- > 2.26.2 >