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

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
The assignable checks are also missing for C++98, but there are types which can
be constructed via std::uninitialized_foo that cannot be assigned to by
std::foo

#include <memory>
#include <algorithm>

struct X;

struct Y
{
  operator X() const;
};

struct X
{
private:
  void operator=(const Y&);
};

Y::operator X() const { return X(); }

int main()
{
  unsigned char buf[sizeof(X)];
  Y y;
  std::uninitialized_fill_n((X*)buf, 1, y);
}

This should copy-construct an X from the result of the conversion operator. But
we optimize it to std::fill_n which tries to use the inaccessible assignment.

/usr/include/c++/11/bits/stl_algobase.h:912:18: error: ‘void X::operator=(const
Y&)’ is private within this context
  912 |         *__first = __value;
      |         ~~~~~~~~~^~~~~~~~~

Reply via email to