[PATCH 1/2] libstdc++: don't implicit-construct _Yielded_decvref [PR118022]
Jonathan Wakely
jwakely.gcc@gmail.com
Thu Dec 26 10:04:28 GMT 2024
On Thu, 26 Dec 2024, 10:03 Jonathan Wakely, <jwakely.gcc@gmail.com> wrote:
>
>
> On Wed, 25 Dec 2024, 01:20 Arsen Arsenović, <arsen@aarsen.me> wrote:
>
>> Evening!
>>
>> This patchset includes fixes for two bugs in libstdc++s implementation
>> of std::generator, namely PR118196 and PR118022.
>>
>> There's little to note about these fixes.
>>
>> Tested on x86_64-pc-linux-gnu via 'make -j17 check' with 'set
>> v3_std_list { 98 11 14 17 20 23 26 }' in the libstdc++ build directory.
>> Will do a full reg-strap before pushing (the testsuite just took far
>> longer than anticipated, so I haven't done it yet).
>>
>> OK for trunk after regstrap?
>>
>
> OK, thanks
>
>
>> TIA, have a lovely day and happy holidays :-)
>> ---------- >8 ----------
>>
>> This overload requires
>>
>> constructible_from<remove_cvref_t<yielded>,
>> const remove_reference_t<yielded>&>
>>
>> ... but then tries to construct remove_cvref_t<yielded> implicitly,
>> which means it imposes an additional constraint not in the standard.
>>
>> libstdc++-v3/ChangeLog:
>>
>> PR libstdc++/118022
>> * include/std/generator
>> (_Promise_erased::yield_value(const _Yielded_deref&)): Don't
>> implicit-constuct _Yielded_decvref.
>> * testsuite/24_iterators/range_generators/pr118022.C: New test.
>>
>
Actually this one should be .cc too.
---
>> libstdc++-v3/include/std/generator | 2 +-
>> .../24_iterators/range_generators/pr118022.C | 16 ++++++++++++++++
>> 2 files changed, 17 insertions(+), 1 deletion(-)
>> create mode 100644
>> libstdc++-v3/testsuite/24_iterators/range_generators/pr118022.C
>>
>> diff --git a/libstdc++-v3/include/std/generator
>> b/libstdc++-v3/include/std/generator
>> index bba85bd0aa4e..3a19d535ef86 100644
>> --- a/libstdc++-v3/include/std/generator
>> +++ b/libstdc++-v3/include/std/generator
>> @@ -144,7 +144,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
>> requires (is_rvalue_reference_v<_Yielded>
>> && constructible_from<_Yielded_decvref,
>> const _Yielded_deref&>)
>> - { return _Copy_awaiter(__val, _M_bottom_value()); }
>> + { return _Copy_awaiter(_Yielded_decvref(__val),
>> _M_bottom_value()); }
>>
>> template<typename _R2, typename _V2, typename _A2, typename _U2>
>> requires std::same_as<_Yield2_t<_R2, _V2>, _Yielded>
>> diff --git
>> a/libstdc++-v3/testsuite/24_iterators/range_generators/pr118022.C
>> b/libstdc++-v3/testsuite/24_iterators/range_generators/pr118022.C
>> new file mode 100644
>> index 000000000000..d8915bb38dc4
>> --- /dev/null
>> +++ b/libstdc++-v3/testsuite/24_iterators/range_generators/pr118022.C
>> @@ -0,0 +1,16 @@
>> +// { dg-do compile { target c++23 } }
>> +#include <generator>
>> +
>> +struct O {
>> + O() = default;
>> + explicit O(const O&) = default;
>> +};
>> +
>> +std::generator<O&&> gen() {
>> + const O o;
>> + co_yield o;
>> +}
>> +
>> +int
>> +main()
>> +{}
>> --
>> 2.47.1
>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://gcc.gnu.org/pipermail/libstdc++/attachments/20241226/ea89b75f/attachment-0001.htm>
More information about the Libstdc++
mailing list