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

            Bug ID: 101663
           Summary: GCC crashes when assigning one single_view to another.
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gcc at zoecarver dot com
  Target Milestone: ---

GCC trunk seems to crash because of a constexpr issue when assigning two single
views with non-assignable types. 

Here's a godbolt: https://tinyurl.com/2edutprj

Here's a sample program:

```
#include <ranges>
#include <cassert>

struct NotAssignable {
  NotAssignable() = default;
  NotAssignable(const NotAssignable&) = default;
  NotAssignable(NotAssignable&&) = default;

  NotAssignable& operator=(const NotAssignable&) = delete;
  NotAssignable& operator=(NotAssignable&&) = delete;
};

constexpr bool test() {
  const std::ranges::single_view<NotAssignable> a;
  std::ranges::single_view<NotAssignable> b;
  b = a;
  b = std::move(a);

  return true;
}

int main(int, char**) {
  test();
  static_assert(test());

  return 0;
}
```

I suspect this is because of optional/copyable box weirdness during constexpr
evaluation. 

I noticed this bug when implementing single_view for libc++. The interesting
part is that this happens with both libstdc++ and libc++. That might help
narrow down the reproducer.

Reply via email to