[Bug libstdc++/93884] ranges::copy doesn't like output iterators

cvs-commit at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon Feb 24 15:12:00 GMT 2020


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93884

--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>:

https://gcc.gnu.org/g:85c143d002a31bebb675161315c8e62db240b636

commit r10-6819-g85c143d002a31bebb675161315c8e62db240b636
Author: Patrick Palka <ppalka@redhat.com>
Date:   Mon Feb 24 07:59:08 2020 -0500

    libstdc++: Add missing bits of P0896R4 pertaining to
[back|front]_insert_iterator

    This adds some missing pieces of the Ranges TS that make
back_insert_iterator and
    front_insert_iterator conform to the new output_iterator requirements.

    It also fixes a bug in ranges::__copy_or_move and
    ranges::__copy_or_move_backward in which we were inspecting the
iter_value_t of
    the output iterator, but output iterators such as back_insert_iterator and
    front_insert_iterator whose value_type = void do not have an iter_value_t
    according to [readable.traits] p4.  The entire __use_memmove condition
should
    probably be rewritten, but the simplest fix for now is to inspect the
    iterator_traits of the output iterator instead.

    libstdc++-v3/ChangeLog:

        PR libstdc++/93884
        * include/bits/ranges_algobase.h (__copy_or_move,
        __copy_or_move_backward): Don't inspect the iter_value_t of the output
        iterator, instead inspect its iterator_traits directly.
        * include/bits/stl_iterator.h (back_insert_iterator::container):
        Conditionally initialize.
        (back_insert_iterator::difference_type): Conditionally define.
        (back_insert_iterator::back_insert_iterator): Conditionally define this
        default constructor.
        (front_insert_iterator::container): Conditionally initialize.
        (front_insert_iterator::difference_type): Conditionally define.
        (front_insert_iterator::front_insert_iterator): Conditionally define
        this default constructor.
        * 24_iterators/back_insert_iterator/pr93884.cc: New test.
        * 24_iterators/front_insert_iterator/pr93884.cc: New test.


More information about the Gcc-bugs mailing list