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.133.124]) by sourceware.org (Postfix) with ESMTPS id 0E88E384F4B7 for ; Thu, 15 Feb 2024 13:17:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0E88E384F4B7 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 0E88E384F4B7 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708003074; cv=none; b=T2+tHpGdd0Vb2XcaGoazA2R3f6pMywAuW2xw3WY4QBY4MAU+KXivp/JpfSZXBcfynuDYs041bwZEVFbjCE3eBDl1V/SdLIi0gKZ23YmnfM3GTrSqWerkebKiZiNal853iyp2MvdfI4FTANLizIFLMP8X0rjuciut6gzVsLWDTHo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708003074; c=relaxed/simple; bh=Vd/EsIPjGAHEzwBeilpOAbQ6ykOCRXhJslKmvseI11c=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=sUIDCBFHfs75KRkHNwy4NRGTfWHh0j8mo1LBgq07IAiCRIJ2LZ66L5K4VPUOeOLc2SP1o7NebV9AaIdQzFKObHJMLaewgwAU608WP+f+loip+6dYPShKzybciEZr0yKJLKt6V4gsgBVLjMzfX1mfRwB+0sMAM992fzj9cQOHnCo= 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-628-IQszv3lANKm5qGo4wLjgfA-1; Thu, 15 Feb 2024 08:17:41 -0500 X-MC-Unique: IQszv3lANKm5qGo4wLjgfA-1 Received: by mail-yb1-f199.google.com with SMTP id 3f1490d57ef6-dc3645a6790so1467230276.0 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=AoIGVRXi7PEgS50wulRoNOnsUjM5yNujbMOVPLWKQfedydjAG0u4VHDL3LjGaoX+GZ oNuyJY/ktI8sZOUt9stOVy1kU9EbQfNbnBGj0rPqEeS/Mh35qCZMVM+m0BuypL5XCGVi lfovx9EQLTZx0dVZIr2qlihVy6nosUD80y8hT42G0ehau3dUjGRWH4wZihXtLntaVzCe hymMrKhzUMpUjYx6FWCi8n55NbLx5HVdpZtqjc4wmC042pcCCQozseutQFlSKNLpoy8Y RgPjUOnDmEEW72dgRe6GUtrnZ035FgqcmqmgyRqdJ5WK+6GRMrKYrxECJsBDPq6s31mC /gmw== X-Forwarded-Encrypted: i=1; AJvYcCULLLuZGx2go3QPx9YMIO7cXO2WUeIUskWeNJt4mn9242gkM8NceSHZaVTTrgs6r8DOUpueydIVN9KJU2F0Q0SG/BOBsSrTpw== X-Gm-Message-State: AOJu0YxHEdVO9vpebo0iF6lK8n8gCZn7xs1ZAG+QjxkAn0RNyVqHYVgy geZIUlU7NuKqBee8T2t23v43m6Fzw4CEhAvaMwggdGshxNEEF4f3xhRlT3Y7u3BbtvumHqUfhkF g9YDaog037tgaAzkCovWdOIvfBt+XyvA97Ij7z1CYrychlrK143P9ZuYzBm6HrzPkdobPYqUmhc sBMYeXTF8utQeRuzAWChW3bLnDak8H2w== X-Received: by 2002:a05:6902:2310:b0:dc7:6f13:61d1 with SMTP id do16-20020a056902231000b00dc76f1361d1mr2047237ybb.20.1708003061129; 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_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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--