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 ESMTP id 95531383D80F for ; Wed, 11 Aug 2021 13:32:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 95531383D80F Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-218-1pU-ZhroPJeLCWfXHCE8PA-1; Wed, 11 Aug 2021 09:32:26 -0400 X-MC-Unique: 1pU-ZhroPJeLCWfXHCE8PA-1 Received: by mail-wr1-f71.google.com with SMTP id o10-20020a5d684a0000b0290154758805bcso745373wrw.3 for ; Wed, 11 Aug 2021 06:32:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=CCXc3WbQzaRPPLE6NzIxid+8T7Be8rdO3sRFbyDqAwg=; b=OyVUCPnrPOFlil/NGRJgoiafzI05Nano5HRVh/Xy9L4veCkDllgfs87b26BaUxV7tJ HHo0SgNKFx8G4BDFVk1Tm3wR9XcYNF4uWIGmGMvv4TCg9BF3/p6c2TqVQDpKp09/5leU fGDsvW49UYGWHCD9eVSGWUWb2953D0HDtFfd7zhXU1mntZK/J47A6PDGJIV2xDNf4UDg gtff/NACpbm97HQqIlYmKv+zkjDBi8XqZek8oS/t0zHGBSuzTp6EejMmV3eV9ALstHS3 sK04EgcpJwQMFgyPZivwrVETnXODTv3iq7dCeAIHFc2uCwHUW6qHJNI+ksgKslmqynxn EHzA== X-Gm-Message-State: AOAM533qyi+7hnPTQU+SqFA/BMiU9DJ6gOfZ4LF93J20p8yFBLd9HQkK aIdRrAYCIN7peba6wZtmBR/xOvr2edNjvJ4DRIV6tqE+N2i48SZRYKFoHnIpGAWSS2DxlhYwvWU TS/pwiqgFNuWhGAGjMtW6C696LO1ieL4= X-Received: by 2002:adf:ee51:: with SMTP id w17mr35630098wro.279.1628688745429; Wed, 11 Aug 2021 06:32:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzgcdCRsEvBY9qp0I/t6Y6MsuYjRo7rwxttEMT2mE5V6RHsphbnDVrUVDel3ISIaT/NA3x7DAY4U00gVa0DFdc= X-Received: by 2002:adf:ee51:: with SMTP id w17mr35630065wro.279.1628688745175; Wed, 11 Aug 2021 06:32:25 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Jonathan Wakely Date: Wed, 11 Aug 2021 14:32:14 +0100 Message-ID: Subject: Re: Unexpected greedy ops failure To: =?UTF-8?Q?Fran=C3=A7ois_Dumont?= Cc: "libstdc++@gcc.gnu.org" X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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, KAM_SHORT, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libstdc++@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++ mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 13:32:39 -0000 On Wed, 11 Aug 2021 at 14:23, Fran=C3=A7ois Dumont via Libstdc++ wrote: > > With the patch proposed in: > https://gcc.gnu.org/pipermail/libstdc++/2021-August/053009.html to > extend some _GLIBCXX_DEBUG checks in _GLIBCXX_ASSERTIONS I have 2 tests > in failure: > > Running target unix/-D_GLIBCXX_DEBUG > Running > /home/fdt/dev/gcc/git/libstdc++-v3/testsuite/libstdc++-dg/conformance.exp > ... > FAIL: 23_containers/deque/types/1.cc (test for excess errors) > FAIL: 23_containers/vector/types/1.cc (test for excess errors) > > The error is: > > /home/fdt/dev/gcc/build/x86_64-pc-linux-gnu/libstdc++-v3/include/debug/he= lper_functions.h:96: > error: ambiguous overload for 'operator-' in '__rhs - __lhs' (operand > types are 'std::move_iterator' and > 'std::move_iterator') > In file included from > /home/fdt/dev/gcc/git/libstdc++-v3/testsuite/23_containers/vector/types/1= .cc:24: > /home/fdt/dev/gcc/git/libstdc++-v3/testsuite/util/testsuite_greedy_ops.h:= 48: > note: candidate: 'greedy_ops::X greedy_ops::operator-(T, T) [with T =3D > std::move_iterator]' > In file included from > /home/fdt/dev/gcc/build/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/stl= _algobase.h:67, > from > /home/fdt/dev/gcc/build/x86_64-pc-linux-gnu/libstdc++-v3/include/vector:6= 0, > from > /home/fdt/dev/gcc/git/libstdc++-v3/testsuite/23_containers/vector/types/1= .cc:23: > /home/fdt/dev/gcc/build/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/stl= _iterator.h:1692: > note: candidate: 'constexpr decltype ((__x.base() - __y.base())) > std::operator-(const std::move_iterator<_IteratorL>&, const > std::move_iterator<_IteratorR>&) [with _IteratorL =3D gree > dy_ops::X*; _IteratorR =3D greedy_ops::X*; decltype ((__x.base() - > __y.base())) =3D long int]' > compiler exited with status 1 > FAIL: 23_containers/vector/types/1.cc (test for excess errors) > > I really don"t understand the link between the failures and this patch. The same tests fail with -std=3Dgnu++20 since Jason made a fix to G++. I haven't decided yet whether we should just disable those tests for C++20, or do something else. Basically, the "greedy" operators on those tests are bad, and nobody should write code like that (C++20 concepts make it unnecessary to do it anyway). > But at the same time I am surprised that there is no definition for > operator-(const move_iterator&, const move_iterator&) in the library > (like in attached patch). With this change the failure vanishes. See line 1689 in > > Moreover is there a reason for having added several operators as normal > std namespace operators rather than inline friend like in my patch ? I > know we already talk about it but I don't remember if the reply was that > we cannot do it or I simply forgot to propose the patch to do so. The standard declares that operator- in namespace std, not as a friend, see the synopsis in [iterator.synopsis]. That has observable semantic effects, e.g. it's possible to call it with: struct X { operator std::move_iterator() const; }; X x; auto d =3D x - x; If the function is only defined as a friend, then it can only be found by ADL, and this example won't compile. I suppose we could add the hidden friend *and* keep the generic overload at namespace scope. That would meet the requirements of the standard. I think we would still have the problem with greedy operators for comparing related but not identical types, e.g. move_iterator and move_iterator.