From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id E462C385022E for ; Thu, 15 Feb 2024 13:17:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E462C385022E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org E462C385022E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708003068; cv=none; b=pG6jBg1XC6txFGO+6LkrmO4yg+nlOMDSHXEUXR/kaKL1Zos7cekOGJ1xDspdX1kE9jN1dqMio8Uxy0smk/RJrpZC9bJF2h6SI33/NH5k1bkGEU2gX4m+ii5MQCuI/vhurTr+Ai8BL27REBNVZXeIWi1iONye20xXoDBNsrr/1cc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708003068; c=relaxed/simple; bh=Vd/EsIPjGAHEzwBeilpOAbQ6ykOCRXhJslKmvseI11c=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=G1vqY9uglqNdryoW1G68KmflZLOKT87A6ZzzaYTB55MnM9c4JFsF5AYtmBSb+lKLouM/RZUEe54zcPRY4f0ff4hjr8kf3vFOGvDKayXOqWW1VLkkz5j8NqHmQQU9lV/GTmyxB2rwru6lj4Nv21K+IlgK8LvkBMyOPAZTinxySPI= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1708003063; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=WsmxNc+Kn4LWw33Pj6vLyGNBYpLYYaPRmXgEPh4fSq0=; b=V7Q82pfUo2beMQwUEawOX1z21GMMppO3oZ7NtIq93OS4gT3nsC518NwZWWMyQEg3Osfbb0 Qykl3yMSFuG5YtOIhSlTerbl2rWczdtuI+ZJVSdKP+d1Ne1re6pZySmgch42GuQpuoooe9 i4BmtBX3B5EkZBRFAPs38M2a2f5HtMY= Received: from mail-yb1-f199.google.com (mail-yb1-f199.google.com [209.85.219.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-615-tNY_Ihk2NA-4bZ-ZlA1IZQ-1; Thu, 15 Feb 2024 08:17:41 -0500 X-MC-Unique: tNY_Ihk2NA-4bZ-ZlA1IZQ-1 Received: by mail-yb1-f199.google.com with SMTP id 3f1490d57ef6-dcd1779adbeso1734116276.3 for ; Thu, 15 Feb 2024 05:17:41 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708003061; x=1708607861; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=WsmxNc+Kn4LWw33Pj6vLyGNBYpLYYaPRmXgEPh4fSq0=; b=ViQYcMUvT5K038s42VLZCCNTxSD+vFLuLErlvPatGoDS3v3dhaaXmwSYQrhf1GYrYk CPMBctSOq2Tt4RAr5wrnCD2H/HQ8wi8MW0auoqp1pzCiG+nXVELw4LST3BAz32scdf+O HNnhBGlbl6g4Xky7gq9b/P9qLWyY+4Mq07frT5GeScQ0SPwxBk8rQL9r/ZoShsiIyuJU FCzLwKu10tyzV0LKyz8OmjJYsa2k14i7ZbvU6Amwy6X7j1WEMwd3QYQqbi0jdf0W7xva awCY2bHZNcHGHv9r1wjJiiz9Tq9rTEP0ONjwWdv8xuof7D91GNZTuwP5Rk/3Inf3UbAZ lSkw== X-Gm-Message-State: AOJu0YyDK7gzZLgXl4T5yzK/LP62vP3OK0MeGWG9xN5kLFuxdIP+wGp0 5RD3bwfDejtDgrW50PReScpRmlddiuMWF6HZHuMa6eSQgvIuUlkPy3IYzHLUhdpgzzKnlRvZyYU Z/jRhhN1cJCa2sFv0+2oQ2sdmvvGUY7w/cCAZm8aTpCRJgAtgReor0LmVxtwJiES3Frf2kSk83P Az43hrzyhxih6Ysa9AZmmPEBBq2BweZ6YrgkLVzA== X-Received: by 2002:a05:6902:2310:b0:dc7:6f13:61d1 with SMTP id do16-20020a056902231000b00dc76f1361d1mr2047240ybb.20.1708003061143; Thu, 15 Feb 2024 05:17:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IHg0NtKtriRtgq+YCWdSgGVERqXvN4jc5+KjyCdW3ZCUHwUDACsItr2rNhYJe1oLSXZS+zmQtqKXpIvf+ah8U8= X-Received: by 2002:a05:6902:2310:b0:dc7:6f13:61d1 with SMTP id do16-20020a056902231000b00dc76f1361d1mr2047221ybb.20.1708003060836; Thu, 15 Feb 2024 05:17:40 -0800 (PST) MIME-Version: 1.0 References: <4c78d538-da4d-4a54-987d-3c4257913035@gmail.com> In-Reply-To: From: Jonathan Wakely Date: Thu, 15 Feb 2024 13:17:25 +0000 Message-ID: Subject: Re: [PATCH][_GLIBCXX_DEBUG] Fix std::__niter_base behavior To: =?UTF-8?Q?Fran=C3=A7ois_Dumont?= Cc: "libstdc++" , gcc-patches X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: multipart/alternative; boundary="000000000000b780d806116b737c" X-Spam-Status: No, score=-6.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: --000000000000b780d806116b737c Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, 14 Feb 2024 at 21:48, Fran=C3=A7ois Dumont w= rote: > > On 14/02/2024 20:44, Jonathan Wakely wrote: > > > > On Wed, 14 Feb 2024 at 18:39, Fran=C3=A7ois Dumont > wrote: > >> libstdc++: [_GLIBCXX_DEBUG] Fix std::__niter_base behavior >> >> std::__niter_base is used in _GLIBCXX_DEBUG mode to remove >> _Safe_iterator<> >> wrapper on random access iterators. But doing so it should also preserve >> original >> behavior to remove __normal_iterator wrapper. >> >> libstdc++-v3/ChangeLog: >> >> * include/bits/stl_algobase.h (std::__niter_base): Redefine the >> overload >> definitions for __gnu_debug::_Safe_iterator. >> * include/debug/safe_iterator.tcc (std::__niter_base): Adapt >> declarations. >> >> Ok to commit once all tests completed (still need to check pre-c++11) ? >> > > > The declaration in include/bits/stl_algobase.h has a noexcept-specifier > but the definition in include/debug/safe_iterator.tcc does not have one - > that seems wrong (I'm surprised it even compiles). > > It does ! > The diagnostic is suppressed without -Wsystem-headers: /home/jwakely/gcc/14/include/c++/14.0.1/debug/safe_iterator.tcc:255:5: warn= ing: declaration of 'template constexpr decltype (std::__ niter_base(declval<_Ite>())) std::__niter_base(const __gnu_debug::_Safe_iterator<_Iterator, _Sequence, random_access_iterator_tag>&)' has a different except ion specifier [-Wsystem-headers] 255 | __niter_base(const ::__gnu_debug::_Safe_iterator<_Ite, _Seq, | ^~~~~~~~~~~~ /home/jwakely/gcc/14/include/c++/14.0.1/bits/stl_algobase.h:335:5: note: fr= om previous declaration 'template constexpr decltype (std ::__niter_base(declval<_Ite>())) std::__niter_base(const __gnu_debug::_Safe_iterator<_Iterator, _Sequence, random_access_iterator_tag>&) noexcept (noexcept (is_nothrow_copy_constructible()))>::value))' 335 | __niter_base(const ::__gnu_debug::_Safe_iterator<_Ite, _Seq, | ^~~~~~~~~~~~ It's a hard error with Clang though: deb.cc:7:10: error: call to '__niter_base' is ambiguous > I thought it was only necessary at declaration, and I also had troubles > doing it right at definition because of the interaction with the auto and > ->. > The trailing-return-type has to come after the noexcept-specifier. > Now simplified and consistent in this new proposal. > > > Just using std::is_nothrow_copy_constructible<_Ite> seems simpler, that > will be true for __normal_iterator if > is_nothrow_copy_constructible is true. > > Ok > > > The definition in include/debug/safe_iterator.tcc should use > std::declval<_Ite>() not declval<_Ite>(). Is there any reason why the > definition uses a late-specified-return-type (i.e. auto and ->) when the > declaration doesn't? > > > I initially plan to use '-> std::decltype(std::__niter_base(__it.base()))' > but this did not compile, ambiguity issue. So I resort to using > std::declval and I could have then done it the same way as declaration, > done now. > > Attached is what I'm testing, ok to commit once fully tested ? > OK, thanks. --000000000000b780d806116b737c--