From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) by sourceware.org (Postfix) with ESMTPS id 3DB0F3860745; Mon, 19 Feb 2024 07:07:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3DB0F3860745 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 3DB0F3860745 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::633 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708326480; cv=none; b=IDocswxnKsTd2PVHx2qrywYXZz4NcSavVKEu4yMVtJiDumCcdREA8PO/CgcIXlYZAlenQxI+r2hmGEyTYjuaNYNu+KiQ+FLO3k5F5GpgsAR0f1THKsLF9l4MDv/mcVuzXc1wUdGZR24GIiZ8M0S7ij654hQF30+dDrZaxv4Vr7E= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708326480; c=relaxed/simple; bh=HelNHOtn1gRiuK53RiX2rhLDjWyni5bQksdDdcpDPNg=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=KFlN9tFBv2JC+EZEx2b89IkILZL9yt5HesWObH6z6EVqOVL562XPtayPMdP4kaoeiRxOiAnjXb6aqRZfUA+pgqSPdrfWbQKRWpVNgWRosQJFN+TUz7UKJPSxffPF5yX7VZJheMSw9gU0n7PSxKilP8D0eH7NTovpdIW2REnVENE= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ej1-x633.google.com with SMTP id a640c23a62f3a-a3122b70439so463670866b.3; Sun, 18 Feb 2024 23:07:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708326472; x=1708931272; 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=kf/1Ac/CjX4gXRNrQ1MNO+ln7o9o1eTS+RiKlVM8SqE=; b=lQTFHhrwon/o3TJpEoriUrntNB30X21vQ7gC/sSxlaimB7Hhyr8DRF/Lb2axS70q9c L0ZIKX91O7cw78oQ6PL6GiFA1bKGA5AaFeeXVuHQGDYPHwQljr+Fc85YWxAUtXaf1VsX uuqYOZYWEl9Q6spv5wNn12+DFUoyGoBUCm+vukUvM01GdoyYjj+0+QPFF8eh82IkRbD2 tY0HzGwQiuN1yS6Mfb5elqLnWdWS9cVxgllJ/pH1C/JmboG9lvg1oy4ZdrfDHgUpkwRd ejSHoVI5K75cBTV9+J/lV2Zbo3lD0qgZXbCM9ml1sQAmbZd1033CzXm4kCZQRGutfZEg w4/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708326472; x=1708931272; 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=kf/1Ac/CjX4gXRNrQ1MNO+ln7o9o1eTS+RiKlVM8SqE=; b=Wc8HJ7JfWMTXtufK0NZEq428DK7LNd4Szvzerq2l51jTdWjv+TxaYa9owb8Q+krM/4 OTFqhp61UMjaI4Q20eIJe2k/9k2fTx513FQQalTstevcdE+/8wC7T24CW1tvCLlN3Kjm J4idkG1+28GG/1nw3ljwGGiPfl1/MwA5h9Sn4fLxtn7ICDy8oL17OC8Kb1D1GnNuyFtA iYh3/g8LLb6iK02Yv1DuLu01FLxaztoIvnt4zWYjtZY2ovquG+pamLK2F13CwLjE8nQF Lkklmt8IwU1zwwIjh74wMN5CSkMZ18+VLfvpNKptAgua1dWXYng+dwgJcLvoeNkuPDmI J91g== X-Gm-Message-State: AOJu0Yz4aBIhUsQrKBV4LSOxuzIVz0gIfvr9R5M52w890aOh09sInqu9 cJDjjyMkg+A/uE75Sb7toKBitTP+9fBo29X9jfpNwO4+ZT5rhYwF35hRrTlR X-Google-Smtp-Source: AGHT+IH5+aGJoSu/T3yzh9KdUKDaY0zHNfeqrqdIbkvejNwUv9KnOgFA/YlKZgnyPzQ2DkNgrKgadg== X-Received: by 2002:a17:906:6857:b0:a3e:cdad:9ebd with SMTP id a23-20020a170906685700b00a3ecdad9ebdmr97719ejs.5.1708326471494; Sun, 18 Feb 2024 23:07:51 -0800 (PST) Received: from [192.168.178.53] (i59F6C6AB.versanet.de. [89.246.198.171]) by smtp.gmail.com with ESMTPSA id s11-20020a1709062ecb00b00a3ce60b003asm2658051eji.176.2024.02.18.23.07.50 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 18 Feb 2024 23:07:51 -0800 (PST) Message-ID: Date: Mon, 19 Feb 2024 08:07:50 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH][_GLIBCXX_DEBUG] Fix std::__niter_base behavior To: libstdc++ Cc: gcc-patches , =?UTF-8?Q?Fran=C3=A7ois_Dumont?= , 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: Stephan Bergmann In-Reply-To: <3e1e1652-4320-4b63-a72f-572f045780ca@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=2.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,KAM_ASCII_DIVIDERS,RCVD_IN_BARRACUDACENTRAL,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-Level: ** X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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 > >, __debug::vector, random_access_iterator_tag>; _To = __gnu_cxx::__normal_iterator > >]’: > ~/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 > >’ 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 >; 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 > >::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 > >’ 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 > >’ 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 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)); } > | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~