public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/100824] New: ranges::size should treat the subexpression as an lvalue
@ 2021-05-29 11:17 hewillk at gmail dot com
  2021-06-03 15:13 ` [Bug libstdc++/100824] " redi at gcc dot gnu.org
                   ` (14 more replies)
  0 siblings, 15 replies; 16+ messages in thread
From: hewillk at gmail dot com @ 2021-05-29 11:17 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 100824
           Summary: ranges::size should treat the subexpression as an
                    lvalue
           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: ---

The CPO described in [range.access] treats the subexpression E as an lvalue,
but ranges::size, ranges::empty, and ranges::data forward E perfectly, which
makes the following case behavior wrong:

https://godbolt.org/z/7KoT3WE41

#include <ranges>
#include <array>

struct R : std::ranges::view_base {
  constexpr int* begin() & { return nullptr; }
  constexpr int* end() & { return nullptr; }
  constexpr int size() & { return 42; }
};
template <>
inline constexpr bool std::ranges::enable_borrowed_range<R> = true;

// call ranges::end(e) - ranges::begin(e) incorrectly
static_assert(std::ranges::size(R{}));

int main() {
  std::array r{42, 42, 42};
  // call e.data() correctly
  (r | std::views::all).data();

  // call std::to_address(ranges::begin(e)) incorrectly
  std::ranges::data(r | std::views::all);
}

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

end of thread, other threads:[~2022-09-07 12:32 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-29 11:17 [Bug libstdc++/100824] New: ranges::size should treat the subexpression as an lvalue hewillk at gmail dot com
2021-06-03 15:13 ` [Bug libstdc++/100824] " redi at gcc dot gnu.org
2021-06-04 11:39 ` redi at gcc dot gnu.org
2021-06-04 14:59 ` cvs-commit at gcc dot gnu.org
2021-06-04 16:52 ` hewillk at gmail dot com
2021-06-04 19:18 ` redi at gcc dot gnu.org
2021-06-04 20:42 ` cvs-commit at gcc dot gnu.org
2021-06-04 20:48 ` redi at gcc dot gnu.org
2021-06-05  3:16 ` hewillk at gmail dot com
2021-06-05  6:35 ` redi at gcc dot gnu.org
2021-06-05 10:45 ` cvs-commit at gcc dot gnu.org
2021-06-11 22:25 ` cvs-commit at gcc dot gnu.org
2021-06-11 22:25 ` cvs-commit at gcc dot gnu.org
2021-06-11 22:25 ` cvs-commit at gcc dot gnu.org
2022-09-07 12:32 ` redi at gcc dot gnu.org
2022-09-07 12:32 ` redi 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).