https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96269
Jonathan Wakely <redi at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Last reconfirmed| |2020-11-05 Keywords| |rejects-valid Assignee|unassigned at gcc dot gnu.org |redi at gcc dot gnu.org Ever confirmed|0 |1 Status|UNCONFIRMED |ASSIGNED --- Comment #8 from Jonathan Wakely <redi at gcc dot gnu.org> --- Ah, but there is a library bug here after all. The declval expressions used to constrain the comparison operators are using the wrong type. They always use declval<_Tp>() == declval<_Up>() but it should be const _Tp& and const _Up& instead. That would mean those aren't candidates for your non-const operator== and so the synthesized operator==(nulloptr_t, optional<T>) would get used.