From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by sourceware.org (Postfix) with ESMTPS id C2FAD386C5B3; Thu, 15 Feb 2024 18:38:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C2FAD386C5B3 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org C2FAD386C5B3 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::32a ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708022336; cv=none; b=mBF7SZ2M25+DTbBOhd35f96lvbENKbURRvMgZm0LPYcX6SXXobPK2DHlmO8Lybe6bJsYj88Ye+SSwrZAjpc5soFZj7rO0PhmDcmqATA2lG9Y5uK4fqZZ0K2kJBF2zZXUS8Tki06Y0BV3cSo2CLWyaw3I5S856TphUfG2g9jUk5M= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708022336; c=relaxed/simple; bh=w4j6jzZTlvHH/jAePWkQ0tyC9rc5r/kJIX3ynLRN1c8=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=Fq6sz9nkPu7Czkwl/s260rneRlwzoRPUxPxq5NhpuWKUJjsMyJ0ZrVKS4X6H3ymYwQ/G4rHQMr6L7Vb9Fnr3fQ8QiS4Eni71T1NmVLJqCBFqSw+paeaj72C6kmA/c+vQnZsKB1Gf4Vk9os8gulbX2DWsOF9bprAuxV6f9t75beo= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-40fb3b5893eso9323315e9.0; Thu, 15 Feb 2024 10:38:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708022332; x=1708627132; darn=gcc.gnu.org; h=in-reply-to:from:content-language:references:cc:to:subject :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=hlCs68eeBZ2HTFbqrexi+ZgKOO0aMskpTL+zF4Jdjvs=; b=D35Q1paubOPFDzNXMe76J1l4u2ea4oj8Ek+5jRKoAt8RzaJgT6LkO5NCAaKnwjFEE2 0Nc4q8J9RIvyxAx2hdlrfyVyc9/lo1l6qVdwE/X3JRTHmod9cbdHSlWoCNzEGnXq5+fn QY+itWg1CWxRUOlcfM4RmlnjYou5go9QeDBj37RnXQb0r70PhYB6aKI0pJx/BVvCMWPf 2+BzrfA3s86h0DPnz8k+rjhCShKHuGdEnljHrxljIQjAj6fuQnFsFxMYvy43rXWD4Zvq BORTm/EBTyJu74JED/36o/84Q5juEw5goaAWlvXqCMnKQQFyiN2ZCH+kCWdQ0ZoQ75Ly ttQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708022332; x=1708627132; h=in-reply-to:from:content-language:references:cc:to:subject :user-agent:mime-version:date:message-id:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=hlCs68eeBZ2HTFbqrexi+ZgKOO0aMskpTL+zF4Jdjvs=; b=JJZaMhxJ4NZYOtBheXN9KaYpSZW4SICqI69vk59sQOS4rLDjzfhJbJb06aBMVXLbI9 fCt3I/7AVW2A3b5dLag1Ofl2peSsXQrHMMrbRTEhk4g4QiR9zyanWoC+QTlckEGBZBOg rsVEFmtyy7wcnsx3RcoZ++NbuK8TRbTupswqEwbeGSvsMSGBYb8bF1aI5Ui2qnyBApUO rdN4DiL+YUxcHRXAFm7T/BqbaP0ygyrNAFjALoRDz9KidNA5/uWY+9AlGwBYquecybEI xY6ZHSjKWq/bZwIpXGLvDNnHRFecVuMhozXACZRh2aerVsAFn0eEhIj8eDTd5ja+UnFJ kzUA== X-Forwarded-Encrypted: i=1; AJvYcCWuAt3qG+rJ0vSp6/chRTfrz+9ivUHgMKyGYnQ6AkAfolI7nj3GMplFtyqA0A7gPy0ooFD76o6nxsihJhAq9NeGJKnbIpH36g== X-Gm-Message-State: AOJu0YzMdGpk8ck38/U26EXKyJ4ytLp6A5uLeT5cIdOJhmEJkMqS5lJK wyzBtV6+PX2309BrHWrincn0BDMwCBXZG/go3ONC5RaXXcrwd4Qz2plqtPMx X-Google-Smtp-Source: AGHT+IGl0w6+le/A+O6mYk7ohE5g0ky55MXqfBO37LjybPfIuMFLGErpAd01ra5H56qBesKjd1Dwtw== X-Received: by 2002:a05:600c:1d16:b0:40f:b69e:aa20 with SMTP id l22-20020a05600c1d1600b0040fb69eaa20mr2272538wms.11.1708022332150; Thu, 15 Feb 2024 10:38:52 -0800 (PST) Received: from [10.49.1.38] ([89.207.171.131]) by smtp.gmail.com with ESMTPSA id h13-20020a05600016cd00b0033d12895cfdsm1180760wrf.61.2024.02.15.10.38.49 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 15 Feb 2024 10:38:51 -0800 (PST) Content-Type: multipart/alternative; boundary="------------jJukT4JjJ8CEtMmfpMMg25H0" Message-ID: <9a6615ee-0a2c-4bcb-ad13-ba810edb9ee1@gmail.com> Date: Thu, 15 Feb 2024 19:38:46 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH][_GLIBCXX_DEBUG] Fix std::__niter_base behavior To: Jonathan Wakely Cc: libstdc++ , gcc-patches References: <4c78d538-da4d-4a54-987d-3c4257913035@gmail.com> Content-Language: en-US From: =?UTF-8?Q?Fran=C3=A7ois_Dumont?= In-Reply-To: X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,BODY_8BITS,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,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: This is a multi-part message in MIME format. --------------jJukT4JjJ8CEtMmfpMMg25H0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 15/02/2024 14:17, Jonathan Wakely wrote: > > > On Wed, 14 Feb 2024 at 21:48, François Dumont > wrote: > > > On 14/02/2024 20:44, Jonathan Wakely wrote: >> >> >> On Wed, 14 Feb 2024 at 18:39, François 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:warning: > 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=-std=c++98 check-debug I see in debug/libstdc++.log for example: Executing on host: /home/fdumont/dev/gcc/build/./gcc/xg++ -shared-libgcc ... -mshstk -std=c++98 -g -O2 -DLOCALEDIR="." -nostdinc++ -I/home/fdumont/dev/gcc/... /home/fdumont/dev/gcc/git/libstdc++-v3/testsuite/25_algorithms/copy/3.cc -D_GLIBCXX_DEBUG   -std=gnu++17  -include bits/stdc++.h ...  -lm -o ./3.exe    (timeout = 360) The -std=c++98 is there but later comes the -std=gnu++17 so I think it runs in C++17, no ? I also tried the documented alternative: make check 'RUNTESTFLAGS=--target_board=unix/-O3\"{-std=gnu++98,-std=gnu++11,-std=gnu++14}\"' but same problem, -std=gnu++17 comes last. I'll try to rebuild all from scratch but I won't commit soon then. --------------jJukT4JjJ8CEtMmfpMMg25H0--