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.129.124]) by sourceware.org (Postfix) with ESMTPS id 6CB0A385800D for ; Tue, 26 Mar 2024 10:59:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6CB0A385800D 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 6CB0A385800D Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711450784; cv=none; b=nBZZ59bF0W1eS+kAkTty6zgWKtH1kZceTTX9kf06+xstTlLtgTBnQfB2VGtagM/aCjZfUd3NtmEfwxtvxNMb/I5ef1BlRtPeD6+2uJs8mXYZX0seaLcc1Swnn3Hzt5REjoIMxHht/P1c69x6MLSe0U+rbco6V7zLlMwsE4Cfi7I= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711450784; c=relaxed/simple; bh=vh5XZZs1GpQj6mQENjBrHPXP9e7URP6I3YbdXdlzIfw=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=QoTXCWkbD0o9clGPQkf9qys433O3OF3JZcNW+wV24p9OUZ9/oGBngPIJt01kxSLEddu+ZWUUIBbHMTeuBDcroJrtxg9mDxPChiqvBTyHkLiD7fDbUA9437DAJXUMIaZXh5WzJ7rbJIqvBZtISAYrNudIgl9XUKfNkiIfvI6mFg0= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1711450782; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3l8nI9jDpdXVrp33KTfonEmT+k8cJNrYoAHJEJ0ZUqw=; b=bjlir58nLabSuo/z9CNlQqFtaBI25I9zTZ6saC2nC9h1Zmi4dvTuO/LAViUsF7hIhHPXk7 D12kd7N5dq20bipXFI3yLmllD76alUmTn3J2YftTVsFpW7SWe+Cfcl+X6CYwQ86eVovHeD I4zMCstgR97Xt/mS9rQ+LiK/LFdgd3s= Received: from mail-yb1-f197.google.com (mail-yb1-f197.google.com [209.85.219.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-597-njLT-RitMRaTLpNQxWYI3w-1; Tue, 26 Mar 2024 06:59:40 -0400 X-MC-Unique: njLT-RitMRaTLpNQxWYI3w-1 Received: by mail-yb1-f197.google.com with SMTP id 3f1490d57ef6-dc64f63d768so8946540276.2 for ; Tue, 26 Mar 2024 03:59:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711450780; x=1712055580; h=content-transfer-encoding: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=3l8nI9jDpdXVrp33KTfonEmT+k8cJNrYoAHJEJ0ZUqw=; b=dnUq+QHtQ6+f0bGhTNgRcYh/WFN6UA5KDpUD/Wk0FL+McSrMS/vuQ/G76gJPSRbcbv uT7AuikpgTN0P99HvpTrCWaN1OCN8dbjgr/ibMk2+ishQxnxC/uYTw9AymReo3HeEc9d Ft55Ftk3QLpbDGZif759lUhYSrs/2Vg/he5dGRnT7Zc8sEeNVBu6yPCLKZY3s8wZw/IP SQqzUo5UixQKa3waIbuIOAwjulhsud9GgUVs/EbhlcnOM82u+mFSwLXWN1cE8otTTQke V+IKxTzl6SGWL/z5cEQwG7XzzcqNwyrJ6sXiXLF6JMMlp3vjA9/bu79dmUvLKsL3FFTH fRgw== X-Forwarded-Encrypted: i=1; AJvYcCUDYde417sQ5UlxvvcLUayUAHA0iGcFNENqEZsTZMjp3jbUzRy0t8h5FpuPDPNo5CsjZEOna0/T0T0dMrd9GP1eMgWqzHw= X-Gm-Message-State: AOJu0YzRaVBv4aQipv10cYJLCCpgnUaFyivFRYaY6EMMVDNfgh1OF9Wh h/xkwBLt0VQjMNqX262v83eTtCXJg/tkgQchRZRYquBTgjWGVP38UTCzeq0q6Z+AGNsq5AYktHA BJ4245AssLGE9XlL7VLNk3nXWDGE9Z1iaffGCwnIUK3raoXxe8oiDocmeN0Msbbx6gLRfN0lmUB r+n+Ak7aO0h+B6x3h2uh7kRtMQQPc= X-Received: by 2002:a25:fc07:0:b0:dcf:ad31:57c9 with SMTP id v7-20020a25fc07000000b00dcfad3157c9mr7258133ybd.0.1711450780305; Tue, 26 Mar 2024 03:59:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHhgPFULa4gjybFLtFUeTFOgK+S/XnhIoTn5f8sbvthE0/NcZ7mp+YFoc1qq8e9KopxoqghEn7FsqMApr5wAZ0= X-Received: by 2002:a25:fc07:0:b0:dcf:ad31:57c9 with SMTP id v7-20020a25fc07000000b00dcfad3157c9mr7258122ybd.0.1711450779893; Tue, 26 Mar 2024 03:59:39 -0700 (PDT) MIME-Version: 1.0 References: <20240323154205.1907790-1-arsen@aarsen.me> <20240323154205.1907790-3-arsen@aarsen.me> In-Reply-To: <20240323154205.1907790-3-arsen@aarsen.me> From: Jonathan Wakely Date: Tue, 26 Mar 2024 10:59:23 +0000 Message-ID: Subject: Re: [PATCH 2/2] libstdc++: fix generator iterator operator* return type To: =?UTF-8?Q?Arsen_Arsenovi=C4=87?= Cc: gcc-patches@gcc.gnu.org, 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=-12.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,KAM_SHORT,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP 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: On Sat, 23 Mar 2024 at 15:47, Arsen Arsenovi=C4=87 wrote: > > Per the standard, the return type of a generators ranges iterator op* > should be the reference type rather than the yielded type. > > The yielded type was used here by mistake. > > libstdc++-v3/ChangeLog: > > * include/std/generator (generator::_Iterator::operator*): Fix > return type. > * testsuite/24_iterators/range_generators/iter_deref_return.cc: > New test. > --- > libstdc++-v3/include/std/generator | 4 +-- > .../range_generators/iter_deref_return.cc | 34 +++++++++++++++++++ > 2 files changed, 36 insertions(+), 2 deletions(-) > create mode 100644 libstdc++-v3/testsuite/24_iterators/range_generators/= iter_deref_return.cc > > diff --git a/libstdc++-v3/include/std/generator b/libstdc++-v3/include/st= d/generator > index 2d1dcced1e57..789016b5a883 100644 > --- a/libstdc++-v3/include/std/generator > +++ b/libstdc++-v3/include/std/generator > @@ -773,12 +773,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION > operator++(int) > { this->operator++(); } > > - yielded > + _Reference > operator*() > const noexcept(is_nothrow_move_constructible_v<_Reference>) > { > auto& __p =3D this->_M_coro.promise(); > - return static_cast(*__p._M_value()); > + return static_cast<_Reference>(*__p._M_value()); > } > > private: > diff --git a/libstdc++-v3/testsuite/24_iterators/range_generators/iter_de= ref_return.cc b/libstdc++-v3/testsuite/24_iterators/range_generators/iter_d= eref_return.cc > new file mode 100644 > index 000000000000..7bdbf4d489ec > --- /dev/null > +++ b/libstdc++-v3/testsuite/24_iterators/range_generators/iter_deref_ret= urn.cc > @@ -0,0 +1,34 @@ > +// { dg-do compile { target c++23 } } > +// Copyright (C) 2023-2024 Free Software Foundation, Inc. Just 2024 here. > +// > +// This file is part of the GNU ISO C++ Library. This library is free > +// software; you can redistribute it and/or modify it under the > +// terms of the GNU General Public License as published by the > +// Free Software Foundation; either version 3, or (at your option) > +// any later version. > + > +// This library is distributed in the hope that it will be useful, > +// but WITHOUT ANY WARRANTY; without even the implied warranty of > +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > +// GNU General Public License for more details. > + > +// Under Section 7 of GPL version 3, you are granted additional > +// permissions described in the GCC Runtime Library Exception, version > +// 3.1, as published by the Free Software Foundation. > + > +// You should have received a copy of the GNU General Public License and > +// a copy of the GCC Runtime Library Exception along with this program; > +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see > +// . I don't think we want the last two paragraphs about the runtime exception. That's relevant to code being compiled into the users binary as inline functions or templates, which doesn't matter for testcases. I see we have 10 existing tests that use the runtime exception text, which I'll fix. For comparison, there are 9000 tests with the GPL text, so the vast majority don't have the exception. OK for trunk with the copyright date fixed and the exception text dropped, thanks. > + > +#include > + > +// Check that the return type of iterator::operator* is the reference ty= pe. > +// Pre-op* return type fix, this'd have resulted in a op* return type of= const > +// bool&. > + > +std::generator > +foo(); > + > +static_assert(std::is_same_v); > +static_assert(std::is_same_v); > -- > 2.44.0 >