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

--- Comment #2 from Avi Kivity <a...@cloudius-systems.com> ---
I think the middle-end knows it is safe to write to *this, because this is
happening in a constructor, so all of the object's memory is known clobbered.

Similarly, if the assignment operator is written as


  optional& optional::operator=(optional&& x) noexcept(...) {
    if (this != &x) {
      this->~optional();
      new (this) optional(std::move(x));
    }
  }

then it has the same information during assignment.

Implementation in the middle end is more useful, because then you don't need
very careful coding of the type, or to depend on is_trivial_foo<>; more user
code will benefit.

Reply via email to