public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/101231] New: _CachedPosition::_M_get() should not return {} when range adapter does not model forward_range
@ 2021-06-27  8:15 hewillk at gmail dot com
  2021-06-28 15:04 ` [Bug libstdc++/101231] " ppalka at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: hewillk at gmail dot com @ 2021-06-27  8:15 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 101231
           Summary: _CachedPosition::_M_get() should not return {} when
                    range adapter does not model forward_range
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hewillk at gmail dot com
  Target Milestone: ---

After P2325, iterators such as basic_istream_view::iterator are no longer
default_initializable, so _CachedPosition::_M_get() should not just return {}
when the adapter does not model forward_range.

#include <ranges>
#include <sstream>

int main() {
  auto words = std::istringstream{"42"};
  auto is = std::ranges::istream_view<int>(words);
  auto r = is | std::views::filter([](auto) { return true; });
  for (auto x : r);
}


https://godbolt.org/z/PejdYzc8j

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libstdc++/101231] _CachedPosition::_M_get() should not return {} when range adapter does not model forward_range
  2021-06-27  8:15 [Bug libstdc++/101231] New: _CachedPosition::_M_get() should not return {} when range adapter does not model forward_range hewillk at gmail dot com
@ 2021-06-28 15:04 ` ppalka at gcc dot gnu.org
  2021-07-16 13:47 ` cvs-commit at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: ppalka at gcc dot gnu.org @ 2021-06-28 15:04 UTC (permalink / raw)
  To: gcc-bugs

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

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |ppalka at gcc dot gnu.org
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2021-06-28
     Ever confirmed|0                           |1
                 CC|                            |ppalka at gcc dot gnu.org

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libstdc++/101231] _CachedPosition::_M_get() should not return {} when range adapter does not model forward_range
  2021-06-27  8:15 [Bug libstdc++/101231] New: _CachedPosition::_M_get() should not return {} when range adapter does not model forward_range hewillk at gmail dot com
  2021-06-28 15:04 ` [Bug libstdc++/101231] " ppalka at gcc dot gnu.org
@ 2021-07-16 13:47 ` cvs-commit at gcc dot gnu.org
  2021-07-16 13:53 ` ppalka at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-07-16 13:47 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 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:1af937eb6246ad7f63ebff03590e9eede33aca81

commit r12-2357-g1af937eb6246ad7f63ebff03590e9eede33aca81
Author: Patrick Palka <ppalka@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++/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.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libstdc++/101231] _CachedPosition::_M_get() should not return {} when range adapter does not model forward_range
  2021-06-27  8:15 [Bug libstdc++/101231] New: _CachedPosition::_M_get() should not return {} when range adapter does not model forward_range hewillk at gmail dot com
  2021-06-28 15:04 ` [Bug libstdc++/101231] " ppalka at gcc dot gnu.org
  2021-07-16 13:47 ` cvs-commit at gcc dot gnu.org
@ 2021-07-16 13:53 ` ppalka at gcc dot gnu.org
  2022-02-11 14:04 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: ppalka at gcc dot gnu.org @ 2021-07-16 13:53 UTC (permalink / raw)
  To: gcc-bugs

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

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
   Target Milestone|---                         |12.0
         Resolution|---                         |FIXED

--- Comment #2 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Fixed for GCC 12.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libstdc++/101231] _CachedPosition::_M_get() should not return {} when range adapter does not model forward_range
  2021-06-27  8:15 [Bug libstdc++/101231] New: _CachedPosition::_M_get() should not return {} when range adapter does not model forward_range hewillk at gmail dot com
                   ` (2 preceding siblings ...)
  2021-07-16 13:53 ` ppalka at gcc dot gnu.org
@ 2022-02-11 14:04 ` cvs-commit at gcc dot gnu.org
  2022-05-31 18:39 ` cvs-commit at gcc dot gnu.org
  2022-05-31 18:46 ` ppalka at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-02-11 14:04 UTC (permalink / raw)
  To: gcc-bugs

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
<ppalka@gcc.gnu.org>:

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

commit r11-9557-g18b7cbb2ac0bf676846d7fe68283f093825357f6
Author: Patrick Palka <ppalka@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)

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libstdc++/101231] _CachedPosition::_M_get() should not return {} when range adapter does not model forward_range
  2021-06-27  8:15 [Bug libstdc++/101231] New: _CachedPosition::_M_get() should not return {} when range adapter does not model forward_range hewillk at gmail dot com
                   ` (3 preceding siblings ...)
  2022-02-11 14:04 ` cvs-commit at gcc dot gnu.org
@ 2022-05-31 18:39 ` cvs-commit at gcc dot gnu.org
  2022-05-31 18:46 ` ppalka at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-05-31 18:39 UTC (permalink / raw)
  To: gcc-bugs

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

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

https://gcc.gnu.org/g:656cd10436260de997f5202b6737c7b8aebdfb4f

commit r10-10809-g656cd10436260de997f5202b6737c7b8aebdfb4f
Author: Patrick Palka <ppalka@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)

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libstdc++/101231] _CachedPosition::_M_get() should not return {} when range adapter does not model forward_range
  2021-06-27  8:15 [Bug libstdc++/101231] New: _CachedPosition::_M_get() should not return {} when range adapter does not model forward_range hewillk at gmail dot com
                   ` (4 preceding siblings ...)
  2022-05-31 18:39 ` cvs-commit at gcc dot gnu.org
@ 2022-05-31 18:46 ` ppalka at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: ppalka at gcc dot gnu.org @ 2022-05-31 18:46 UTC (permalink / raw)
  To: gcc-bugs

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

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|12.0                        |10.4

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-05-31 18:46 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-27  8:15 [Bug libstdc++/101231] New: _CachedPosition::_M_get() should not return {} when range adapter does not model forward_range hewillk at gmail dot com
2021-06-28 15:04 ` [Bug libstdc++/101231] " ppalka at gcc dot gnu.org
2021-07-16 13:47 ` cvs-commit at gcc dot gnu.org
2021-07-16 13:53 ` ppalka at gcc dot gnu.org
2022-02-11 14:04 ` cvs-commit at gcc dot gnu.org
2022-05-31 18:39 ` cvs-commit at gcc dot gnu.org
2022-05-31 18:46 ` ppalka at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).