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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |INVALID

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
The code is valid. The optional<T>::operator=(U&&) assignment operator is not
used when is_scalar<T> and is_same<T, decay_T<U>> (which is true here, where
T=int and U=int).

That means the assignment creates a temporary optional<int> using the constexpr
constructor, i.e.

  bar = std::optional<int>(10);

This is valid in a constexpr function.

Reply via email to