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

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Patrick Palka
<ppa...@gcc.gnu.org>:

https://gcc.gnu.org/g:18b7cbb2ac0bf676846d7fe68283f093825357f6

commit r11-9557-g18b7cbb2ac0bf676846d7fe68283f093825357f6
Author: Patrick Palka <ppa...@redhat.com>
Date:   Fri Jul 16 09:44:42 2021 -0400

    libstdc++: invalid default init in _CachedPosition [PR101231]

    The primary template for _CachedPosition is a dummy implementation for
    non-forward ranges, the iterators for which generally can't be cached.
    Because this implementation doesn't actually cache anything, _M_has_value
    is defined to be false and so calls to _M_get (which are always guarded
    by _M_has_value) are unreachable.

    Still, to suppress a "control reaches end of non-void function" warning
    I made _M_get return {}, but after P2325 input iterators are no longer
    necessarily default constructible so this workaround now breaks valid
    programs.

    This patch fixes this by instead using __builtin_unreachable to squelch
    the warning.

            PR libstdc++/103904
            PR libstdc++/101231

    libstdc++-v3/ChangeLog:

            * include/std/ranges (_CachedPosition::_M_get): For non-forward
            ranges, just call __builtin_unreachable.
            * testsuite/std/ranges/istream_view.cc (test05): New test.

    (cherry picked from commit 1af937eb6246ad7f63ebff03590e9eede33aca81)

Reply via email to