From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by sourceware.org (Postfix) with ESMTPS id A9B213858D20 for ; Mon, 19 Feb 2024 17:59:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A9B213858D20 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 A9B213858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::330 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708365553; cv=none; b=fWrWFeWcm449ZbzIcE0JcMBD3TaIdx2lfO+hkMCcggRbgY48vYtEJIAa9VRPjPm9IwJJ0D2agR/9hqxt3XoAuNFeKSGHU1VHwQeReVv9GmBHRoWdo8+5Pn1IKiZykCrWpCcHkiJ+NwqYi31I4Q9Yk5Jws2rZQpUipsACBCSq3yw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708365553; c=relaxed/simple; bh=MO1XYmV5cOYBzwipP1PD2BA/2Pt1mPESbFSzKrhdcI8=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=tD0U++5vg1/D55JDAOGFba6LuEe9ILvgMvtm0jozYuWtsg+B9PjFCH2zkPfSE+UAMV8tAvzocmwHTAj8+qpkz28EcmdoAvo4htMuNGvqIyfsgzLJtXdjrWLpdJmcA3xcwOCN6XZUEc9cnMCANox4gxkC90UcJHwWfWSE3k2JI2o= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-41264195d5cso11785825e9.1 for ; Mon, 19 Feb 2024 09:59:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708365550; x=1708970350; darn=gcc.gnu.org; h=content-transfer-encoding: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=sWgRf598VRTTE2qTrsbPEGh3gDmDkQPYMJPtMOZi/f8=; b=mgvyfR3YLUK3HtL4UIWQqaEilw0V/rQaWMKkkDd3r0tKIkubGpTUgA4MMQ3Wdt85cQ R6JvRsBo5/6WrvLFXm7Ded3lG4l3LgUm53oJQ9okoATnSVd/lGVouSH2FjM0zVvsXmNr Cw7njDdmsDepudFiXEPfHTmDqfISU3ur9sfe8CDkEIuhzl7ga3HC40uHnsktpPKFtAA5 0uu523nszkYUdux+VexTDciaFFa49w7hE1q9aSymqTeukzu8a4k9Dzkrx28bgiE70apd 8D2K8sRRSogLX2pbVNRzjZCtB0wJPMAqdU9stqlWHRXAUrXCzCXRdjo2mfg5kNTm78hc ozZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708365550; x=1708970350; h=content-transfer-encoding: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=sWgRf598VRTTE2qTrsbPEGh3gDmDkQPYMJPtMOZi/f8=; b=b2WAgYm6swAvS2Xd6tefB/0w+x6CGQL4uIVSK1kbIkby7QXmghsqtCM1RyneTWGPYO kqiT1c94MVD/+S5FxT9JEWtNtDpIgyRa1BHsj0Ka5cDCWYH1/uDTfreIN4mMbTDYZ0QF 5vRWUGquQGoJ4AJ9Dfh/S3/oohuYUg+WxFNGxwl5dtDCQ+pgNnGszDSDQ1aVR3abxoKx ng0V6C5acjzcZbMUHBNQEcL6Hk+Agwj8idb23i7dgAMWRVzDvo5C9bVEF0uHdG+RdsTy D8KeZI+8ZmZL97YQLieGfLfTbJ0Muk6bGNBE1D7Z+pIl7bOBBiExQjSCxM8l7UTp+NI8 2smA== X-Forwarded-Encrypted: i=1; AJvYcCVPqC+6xtwW74Ei3rGGn6C6HbADYVvfagQ2vxWSSNb03w5CJjh7oXui6ZmdWDADjBeCQJKvMQUKxnp3FhiauBuVJhSr4Ug= X-Gm-Message-State: AOJu0Yw7DLmAIUDO+qiMr2jmNbj+Od/FHwG9Bd+iVQyE2c0DaXi9u3Ht bOnKrv9qo/XFs70x0PHyhHOwdLxB22UX0oe+CiuyT4Cm5RYbVzGg X-Google-Smtp-Source: AGHT+IGQA19RBnpX+pFLxce0JMyxxyqAEiJrQiwe5NrN9/tLUgwvS6BNCrfcqMTbfTw7vu0c8oOELA== X-Received: by 2002:a05:600c:354a:b0:412:5b86:2f2c with SMTP id i10-20020a05600c354a00b004125b862f2cmr4878847wmq.14.1708365550078; Mon, 19 Feb 2024 09:59:10 -0800 (PST) Received: from [10.58.1.174] ([89.207.171.133]) by smtp.gmail.com with ESMTPSA id r13-20020a05600c35cd00b00410c7912c6esm12200395wmq.14.2024.02.19.09.59.09 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 19 Feb 2024 09:59:09 -0800 (PST) Message-ID: <0fbe734d-b8d6-4d03-a326-d3137e84c701@gmail.com> Date: Mon, 19 Feb 2024 18:59:08 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH][_GLIBCXX_DEBUG] Fix std::__niter_base behavior To: Stephan Bergmann , libstdc++ Cc: Jonathan Wakely References: <4c78d538-da4d-4a54-987d-3c4257913035@gmail.com> <9a6615ee-0a2c-4bcb-ad13-ba810edb9ee1@gmail.com> <3e1e1652-4320-4b63-a72f-572f045780ca@gmail.com> Content-Language: en-US From: =?UTF-8?Q?Fran=C3=A7ois_Dumont?= In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,BODY_8BITS,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,KAM_ASCII_DIVIDERS,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Surely, checking. On 19/02/2024 08:07, Stephan Bergmann wrote: > On 2/17/24 15:14, François Dumont wrote: >> Thanks for the link, tested and committed. > > I assume this is the cause for the below failure now, > >> $ cat test.cc >> #include >> #include >> void f(std::vector &v, void const * p) { >>     std::erase(v, p); >> } > >> $ ~/gcc/inst/bin/g++ -std=c++20 -D_GLIBCXX_DEBUG -fsyntax-only test.cc >> In file included from ~/gcc/inst/include/c++/14.0.1/algorithm:60, >>                  from test.cc:1: >> ~/gcc/inst/include/c++/14.0.1/bits/stl_algobase.h: In instantiation >> of ‘constexpr _From std::__niter_wrap(_From, _To) [with _From = >> __gnu_debug::_Safe_iterator<__gnu_cxx::__normal_iterator> void**, __cxx1998::vector > >, >> __debug::vector, random_access_iterator_tag>; _To = >> __gnu_cxx::__normal_iterator> void*, allocator > >]’: >> ~/gcc/inst/include/c++/14.0.1/vector:144:29:   required from >> ‘constexpr typename std::__debug::vector<_Tp, _Allocator>::size_type >> std::erase(__debug::vector<_Tp, _Alloc>&, const _Up&) [with _Tp = >> const void*; _Alloc = allocator; _Up = const void*; >> typename __debug::vector<_Tp, _Allocator>::size_type = long unsigned >> int]’ >>   144 |           __cont.erase(__niter_wrap(__cont.begin(), __removed), >>       | ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~ >> test.cc:4:15:   required from here >>     4 |     std::erase(v, p); >>       |     ~~~~~~~~~~^~~~~~ >> ~/gcc/inst/include/c++/14.0.1/bits/stl_algobase.h:347:30: error: no >> match for ‘operator-’ (operand types are >> ‘__gnu_cxx::__normal_iterator> std::__cxx1998::vector > >’ >> and ‘const void**’) >>   347 |     { return __from + (__res - std::__niter_base(__from)); } >>       | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~ >> In file included from >> ~/gcc/inst/include/c++/14.0.1/bits/stl_algobase.h:67: >> ~/gcc/inst/include/c++/14.0.1/bits/stl_iterator.h:1148:7: note: >> candidate: ‘constexpr __gnu_cxx::__normal_iterator<_Iterator, >> _Container> __gnu_cxx::__normal_iterator<_Iterator, >> _Container>::operator-(difference_type) const [with _Iterator = const >> void**; _Container = std::__cxx1998::vector> std::allocator >; difference_type = long int]’ (near match) >>  1148 |       operator-(difference_type __n) const _GLIBCXX_NOEXCEPT >>       |       ^~~~~~~~ >> ~/gcc/inst/include/c++/14.0.1/bits/stl_iterator.h:1148:7: note:   >> conversion of argument 1 would be ill-formed: >> ~/gcc/inst/include/c++/14.0.1/bits/stl_algobase.h:347:49: error: >> invalid conversion from ‘const void**’ to >> ‘__gnu_cxx::__normal_iterator> std::__cxx1998::vector > >> >::difference_type’ {aka ‘long int’} [-fpermissive] >>   347 |     { return __from + (__res - std::__niter_base(__from)); } >>       |                                ~~~~~~~~~~~~~~~~~^~~~~~~~ >>       |                                                 | >>       |                                                 const void** >> ~/gcc/inst/include/c++/14.0.1/bits/stl_iterator.h:618:5: note: >> candidate: ‘template constexpr >> decltype ((__y.base() - __x.base())) std::operator-(const >> reverse_iterator<_IteratorL>&, const reverse_iterator<_IteratorR>&)’ >>   618 |     operator-(const reverse_iterator<_IteratorL>& __x, >>       |     ^~~~~~~~ >> ~/gcc/inst/include/c++/14.0.1/bits/stl_iterator.h:618:5: note: >> template argument deduction/substitution failed: >> ~/gcc/inst/include/c++/14.0.1/bits/stl_algobase.h:347:30: note:   >> ‘__gnu_cxx::__normal_iterator> std::__cxx1998::vector > >’ >> is not derived from ‘const std::reverse_iterator<_IteratorL>’ >>   347 |     { return __from + (__res - std::__niter_base(__from)); } >>       | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~ >> ~/gcc/inst/include/c++/14.0.1/bits/stl_iterator.h:1789:5: note: >> candidate: ‘template constexpr >> decltype ((__x.base() - __y.base())) std::operator-(const >> move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)’ >>  1789 |     operator-(const move_iterator<_IteratorL>& __x, >>       |     ^~~~~~~~ >> ~/gcc/inst/include/c++/14.0.1/bits/stl_iterator.h:1789:5: note:   >> template argument deduction/substitution failed: >> ~/gcc/inst/include/c++/14.0.1/bits/stl_algobase.h:347:30: note:   >> ‘__gnu_cxx::__normal_iterator> std::__cxx1998::vector > >’ >> is not derived from ‘const std::move_iterator<_IteratorL>’ >>   347 |     { return __from + (__res - std::__niter_base(__from)); } >>       | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~ >> ~/gcc/inst/include/c++/14.0.1/bits/stl_iterator.h:1312:5: note: >> candidate: ‘template> _Container> constexpr decltype ((__lhs.base() - __rhs.base())) >> __gnu_cxx::operator-(const __normal_iterator<_IteratorL, >> _Container>&, const __normal_iterator<_IteratorR, _Container>&)’ >>  1312 |     operator-(const __normal_iterator<_IteratorL, >> _Container>& __lhs, >>       |     ^~~~~~~~ >> ~/gcc/inst/include/c++/14.0.1/bits/stl_iterator.h:1312:5: note:   >> template argument deduction/substitution failed: >> ~/gcc/inst/include/c++/14.0.1/bits/stl_algobase.h:347:30: note:   >> mismatched types ‘const __gnu_cxx::__normal_iterator<_IteratorR, >> _Container>’ and ‘const void**’ >>   347 |     { return __from + (__res - std::__niter_base(__from)); } >>       | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~ >> ~/gcc/inst/include/c++/14.0.1/bits/stl_iterator.h:1325:5: note: >> candidate: ‘template constexpr >> typename __gnu_cxx::__normal_iterator<_Iterator, >> _Container>::difference_type __gnu_cxx::operator-(const >> __normal_iterator<_Iterator, _Container>&, const >> __normal_iterator<_Iterator, _Container>&)’ >>  1325 |     operator-(const __normal_iterator<_Iterator, _Container>& >> __lhs, >>       |     ^~~~~~~~ >> ~/gcc/inst/include/c++/14.0.1/bits/stl_iterator.h:1325:5: note:   >> template argument deduction/substitution failed: >> ~/gcc/inst/include/c++/14.0.1/bits/stl_algobase.h:347:30: note:   >> mismatched types ‘const __gnu_cxx::__normal_iterator<_Iterator, >> _Container>’ and ‘const void**’ >>   347 |     { return __from + (__res - std::__niter_base(__from)); } >>       | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~ >