public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/100982] New: wrong constraint in std::optional::operator=
@ 2021-06-09  3:28 hewillk at gmail dot com
  2021-06-09  6:13 ` [Bug libstdc++/100982] " redi at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: hewillk at gmail dot com @ 2021-06-09  3:28 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 100982
           Summary: wrong constraint in std::optional::operator=
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hewillk at gmail dot com
  Target Milestone: ---

There is a typo in optional#L818:

  template<typename _Up>
    enable_if_t<__and_v<__not_<is_same<_Tp, _Up>>,
                is_constructible<_Tp, const _Up&>,
                is_assignable<_Tp&, _Up>,
                __not_<__converts_from_optional<_Tp, _Up>>,
                __not_<__assigns_from_optional<_Tp, _Up>>>,
                optional&>
    operator=(const optional<_Up>& __u)

It should be is_assignable<_Tp&, const _Up&>.

https://godbolt.org/z/x7Gb9a5v9

#include <optional>

struct U {};

struct T {
  explicit T(const U&);
  T& operator=(const U&);
  T& operator=(U&&) = delete;
};

int main() {
  std::optional<U> opt1;
  std::optional<T> opt2;
  opt2 = opt1;
}

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-07-22 21:30 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-09  3:28 [Bug libstdc++/100982] New: wrong constraint in std::optional::operator= hewillk at gmail dot com
2021-06-09  6:13 ` [Bug libstdc++/100982] " redi at gcc dot gnu.org
2021-06-09 11:45 ` cvs-commit at gcc dot gnu.org
2021-06-09 16:31 ` redi at gcc dot gnu.org
2021-06-11 22:26 ` cvs-commit at gcc dot gnu.org
2021-06-14 18:52 ` cvs-commit at gcc dot gnu.org
2021-07-22 21:28 ` cvs-commit at gcc dot gnu.org
2021-07-22 21:30 ` redi at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).