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 57FAF386C583 for ; Thu, 15 Feb 2024 18:40:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 57FAF386C583 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 57FAF386C583 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=1708022430; cv=none; b=ErSyyZDtKT8UM+mdvY6zgWECEJXDUUvOf4fa6P3DKlYSfm0lRGp6TGbXPYXh+nBZ1VIffJxplWFDG/ddd8L+g9bNIQYYVzG0LhHGCPbbQTf6VBYEwbQJmZZNauq4+7GDxcnCe0uyCzHFuWHKySQMd9ApuPV8ej23x/dPSRLeGc0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708022430; c=relaxed/simple; bh=u/IPms7N5NuUgw3/luhlkuGEYruFCyzIjPbOnXlciJE=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=VK5PBRhFsEHfPkc4G62oGFTsmyJKXzEmFbsY+UyZNYI9faA7PY/bl+mbDrrg691H4palvDOglPGdKS5EOTWL1jmvGhlS3ujvXp7rrG+O5gTn6OTiqTzC2Nqto1hera67fqohxW7hlud9KYtec779htBnW8OaXf1mAx6VjbSOQxM= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1708022428; 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=PGXs+oEiUtBasApultKVePlalTtY7K1XjnYigeKlQDw=; b=dOdbjlfLnFti1jsGGgUmSVS9bqbJ99b1FYdJyOS2WHFtNK89CMgBR+DywAyQBe0GRF5wTL ptFSm/UW5DVFWCoxxWPqN3XkIeGgNPHXIXMFh4xv2iMkS38bGFdmKyfnjIyHBqu5qX1M6f Ev0StHj32JecmY0NQy1yS4movswu6zU= Received: from mail-yw1-f200.google.com (mail-yw1-f200.google.com [209.85.128.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-609-l6sLjQ7AOPO5OgIWWgxHag-1; Thu, 15 Feb 2024 13:40:26 -0500 X-MC-Unique: l6sLjQ7AOPO5OgIWWgxHag-1 Received: by mail-yw1-f200.google.com with SMTP id 00721157ae682-602dae507caso20460377b3.0 for ; Thu, 15 Feb 2024 10:40:26 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708022425; x=1708627225; 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=PGXs+oEiUtBasApultKVePlalTtY7K1XjnYigeKlQDw=; b=slb9FDuCGmiSliujg6LAOZMT2Xum+L9iErW5sKegZHkzFgrUVczeyqoMm0sEC/4Gn6 x5L66UArsKxGqTzrcwmHGDNtyrRYjNW6aJ7oP0awF4V3gLIbwNQ3UrJRSoPzrVB3QB2E A75XZHCyK8ofA6/3wa+gm93/KPGk3lfUSEhY1xRVCePy7Dm1EfjAS6RNRkH7pjsgcJgF enlyHaveFXQcB/4fgRQkThUUHyNsfdi+Sy11RM3znKm6RzbwPoyaGx0WAY65KvtssIIh +ecFotUxg4QHtG1RTHRSRGycBH2lzr3CookNt3aUCRIBQWg+9+r/eAJZgdyAwxmAspgm bw+A== X-Gm-Message-State: AOJu0Yxca/kDw71D8WxSy5MVklMkXe7Q0LBm58nQCsLT4ML9VZqAFKao Ho0wLbuyV9iAy6+anyEjf5LsaY4xuP6MXTpoHfJ0bcirXxN20DJHdGmh5yQlhNTuirU/oVXC5H3 Bv5saOC9sggiN+NPPa3KqxH0Bm3n7W8KZfrw/GkyqeCSL5QOs95OQk1xnr0Gu/pDjjidcdiRIMu l0jm62++88opQBtGNcv6DAYkqjgRmbJd4yF7ygqQ== X-Received: by 2002:a81:ac1c:0:b0:607:f09d:b2af with SMTP id k28-20020a81ac1c000000b00607f09db2afmr541109ywh.1.1708022425584; Thu, 15 Feb 2024 10:40:25 -0800 (PST) X-Google-Smtp-Source: AGHT+IGdB/TxLEHrzKGa8a3OOeq8fhSlqqipp48isxUAIRCAn/N5CTilyd/3KNbmeZk1OrHw8JLptdUZl1uP33duGVc= X-Received: by 2002:a81:ac1c:0:b0:607:f09d:b2af with SMTP id k28-20020a81ac1c000000b00607f09db2afmr541093ywh.1.1708022425301; Thu, 15 Feb 2024 10:40:25 -0800 (PST) MIME-Version: 1.0 References: <4c78d538-da4d-4a54-987d-3c4257913035@gmail.com> <9a6615ee-0a2c-4bcb-ad13-ba810edb9ee1@gmail.com> In-Reply-To: <9a6615ee-0a2c-4bcb-ad13-ba810edb9ee1@gmail.com> From: Jonathan Wakely Date: Thu, 15 Feb 2024 18:40:09 +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="000000000000edd65206116ff541" X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,HTML_MESSAGE,KAM_SHORT,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: --000000000000edd65206116ff541 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, 15 Feb 2024 at 18:38, Fran=C3=A7ois Dumont w= rote: > > On 15/02/2024 14:17, Jonathan Wakely wrote: > > > > On Wed, 14 Feb 2024 at 21:48, Fran=C3=A7ois Dumont > wrote: > >> >> 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: wa= rning: > 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: = from > 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 (std::__niter_base(declval<_Ite>()))>::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 > > > Yes, I eventually got the error too, I hadn't run enough tests yet. > > > > > > >> 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. > > Thanks for validation but I have a problem to test for c++98. > > When I do: > > make CXXFLAGS=3D-std=3Dc++98 check-debug > That doesn't work any more, see https://gcc.gnu.org/onlinedocs/libstdc++/manual/test.html#test.run.permutat= ions > I see in debug/libstdc++.log for example: > > Executing on host: /home/fdumont/dev/gcc/build/./gcc/xg++ -shared-libgcc > ... -mshstk -std=3Dc++98 -g -O2 -DLOCALEDIR=3D"." -nostdinc++ > -I/home/fdumont/dev/gcc/... > /home/fdumont/dev/gcc/git/libstdc++-v3/testsuite/25_algorithms/copy/3.cc > -D_GLIBCXX_DEBUG -std=3Dgnu++17 -include bits/stdc++.h ... -lm -o > ./3.exe (timeout =3D 360) > > The -std=3Dc++98 is there but later comes the -std=3Dgnu++17 so I think it > runs in C++17, no ? > > I also tried the documented alternative: > > make check 'RUNTESTFLAGS=3D--target_board=3Dunix/-O3\"{-std=3Dgnu++98,-st= d=3Dgnu++11,-std=3Dgnu++14}\"' > > > but same problem, -std=3Dgnu++17 comes last. > > I'll try to rebuild all from scratch but I won't commit soon then. > > > --000000000000edd65206116ff541--