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 13E39386C589 for ; Thu, 15 Feb 2024 18:40:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 13E39386C589 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 13E39386C589 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=1708022432; cv=none; b=rPPt8UgDjORzkIDtKKrlKtj3SzEwIs+gckewhmXOsMPwV7pGzlh4CiVfJ9j7s5V89iH83StMABMSN3NWdTr7xwMQE7IEN/J5CKZLIU6HASbti4wU5TbjSD3wbdtf5Tm58F5XYeCIxJIqsbJKeXlT4ZBMvl0uJn8+xRBQEsAYTIo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708022432; c=relaxed/simple; bh=u/IPms7N5NuUgw3/luhlkuGEYruFCyzIjPbOnXlciJE=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=RxOya87Tui2xCS35YUvotZaqTGNOQBraOzP1ZkuhtSw1DF9XelNU6FItETJthYK0EoVEVZ9OHOT34K1O6iIHgAJ7EMz3FDYfTF5Htyy6Oom19CNWBsQLXLQsaFE5qSHStMIEFaXvRrrGEeUUnJ+1xGwoV6VeqzK5h96gLWpWqAE= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1708022429; 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=Wzi8cw2npxD7DLc/VyVmUcA4VPS6VAXzQwZ1ErDW21n+vsh+h5/6AOEf0uloKDRj8GE3D3 GZBP/VLzCq5bw1jBZWTYNVXt+rR9UuV18MeM9bW1PXEJIZ3pkQNzHtqP0K/VN2Gq6nfUfP X6SA6+iqfyCbwO3XxwOeb/7YS7vcZsY= 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-664-iB5X4YmKOQ2Jw0eKpiaf4Q-1; Thu, 15 Feb 2024 13:40:26 -0500 X-MC-Unique: iB5X4YmKOQ2Jw0eKpiaf4Q-1 Received: by mail-yw1-f200.google.com with SMTP id 00721157ae682-6078f65697cso18729367b3.2 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=HUxzue1goJ9RwhbVc4O88NDX0HQ06Zk7wiDPtxj6Ju+fKPyzZ3JBZPAAzsIdfbQkrZ COsaKxi3uVPgy1i8Xm2CG+DSfTfBi9ex6TX73ZyP0lk9DJQtmQ2nEOAtowMcXWGIjPpj 3TvTpmOocXD+MoQlwHdxKH0oM9ViMSreum5sSMrjEOtmsZ9paE/xJNQ2BohoWZMerD/k U2aHfpYXaXKjWT8oKfACdHiI6Xb42hiZPwJecvYZWsl3SUf2qE/UnwKFNqqWsb8yuWKE FCgAV4aIA95QKUMtrRpN7BDK4DLD/nWfIxQ19QkbFyuKcSx9xOK6zfvAtywmuIsKX0Lp M5zw== X-Forwarded-Encrypted: i=1; AJvYcCXXkIx7CKwdMTZ2e6y5GcXOaP2zJRCYlFOE6R0zfnM/+RV0m5xYqJaxBGUX6+tt5Vu3+De9uxXc7wBxUAG9/wi4O4y7TBigBA== X-Gm-Message-State: AOJu0YzfIhM0iUYsSyS3Zox+50O2u7FwWx3p9FcTMsVS1gdwQteBBh7c R54HniyfynmhDwKKhF8YJxcbCzXxo/ckXoMauh/yktVuo5Mz2DCMO9Fpll0+pu5d6Ic8P0jlq4v ++A+880W/JJeQoax1mjQG7c3vkq55SyybTPsyqvYDMHYGyvte4uBH6MC6SVPaOUAJYztOaD+4cf 8lsvMxyDmEcSL9FPYM7IiW/z6vf8ANPw== X-Received: by 2002:a81:ac1c:0:b0:607:f09d:b2af with SMTP id k28-20020a81ac1c000000b00607f09db2afmr541108ywh.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.8 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_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: --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--