[llvm-bugs] [Bug 50720] New: Invalid test for views::view_interface

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Jun 15 09:17:42 PDT 2021


https://bugs.llvm.org/show_bug.cgi?id=50720

            Bug ID: 50720
           Summary: Invalid test for views::view_interface
           Product: libc++
           Version: 12.0
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: zilla at kayari.org
                CC: llvm-bugs at lists.llvm.org, mclow.lists at gmail.com

The test std/ranges/range.utility/view.interface/view.interface.pass.cpp uses
this type:

struct MoveOnlyForwardRange : std::ranges::view_interface<MoveOnlyForwardRange>
{
  int buff[8] = {0, 1, 2, 3, 4, 5, 6, 7};
  MoveOnlyForwardRange(MoveOnlyForwardRange const&) = delete;
  MoveOnlyForwardRange(MoveOnlyForwardRange &&) = default;
  MoveOnlyForwardRange() = default;

This violates the precondition for the view_interface base class, because the
type is not assignable so fails to satisfy std::movable, which is required by
the std::ranges::view concept.

You need:


---
a/libcxx/test/std/ranges/range.utility/view.interface/view.interface.pass.cpp
+++
b/libcxx/test/std/ranges/range.utility/view.interface/view.interface.pass.cpp
@@ -77,6 +77,7 @@ struct MoveOnlyForwardRange :
std::ranges::view_interface<MoveOnlyForwardRange>
   int buff[8] = {0, 1, 2, 3, 4, 5, 6, 7};
   MoveOnlyForwardRange(MoveOnlyForwardRange const&) = delete;
   MoveOnlyForwardRange(MoveOnlyForwardRange &&) = default;
+  MoveOnlyForwardRange& operator=(MoveOnlyForwardRange &&) = default;
   MoveOnlyForwardRange() = default;
   constexpr ForwardIter begin() const { return
ForwardIter(const_cast<int*>(buff)); }
   constexpr ForwardIter end() const { return
ForwardIter(const_cast<int*>(buff) + 8); }


Also, your tests seem to be compiled with -Wshadow which causes a failure when
using GCC, because of this type in the test:

   struct SentinelType {
     int *base;
     SentinelType() = default;
     explicit constexpr SentinelType(int *base) : base(base) {}

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210615/beb77ef9/attachment.html>


More information about the llvm-bugs mailing list