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

            Bug ID: 91308
           Summary: [7/8/9/10 Regression] unique_ptr assignment fails with
                    different deleters
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Keywords: rejects-valid
          Severity: minor
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: redi at gcc dot gnu.org
  Target Milestone: ---

As reported at https://gcc.gnu.org/ml/libstdc++/2019-07/msg00088.html this
fails to compile:

#include <memory>

struct D1
{
  void operator()(int* p) const noexcept { }
};

struct D2 : D1
{
  D2& operator=(D1&&) noexcept { return *this; }
};

void
test01()
{
  std::unique_ptr<int, D1> d1;
  std::unique_ptr<int, D2> d2;
  d2 = std::move(d1);
}

void
test02()
{
  std::unique_ptr<int[], D1> d1;
  std::unique_ptr<int[], D2> d2;
  d2 = std::move(d1);
}

The constraints on the converting assignment operators incorrectly include this
constraint from the converting constructor:

— either D is a reference type and E is the same type as D, or D is not a
  reference type and E is implicitly convertible to D.

This used to compile with GCC 5, until r226733.

Reply via email to