This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] Fix libstdc++/55043 - issue with nesting unordered_map containing unique_ptr into vector


Here's another attempt to fix this regression, I hope this time it
doesn't cause more problems than it solves.

Instead of specializing is_copy_constructible for the unordered
containers this causes their copy constructors to be deleted if the
value_type is not CopyInsertable into the container.  This makes
is_copy_constructible naturally give the right result, and so
__move_if_noexcept does the right thing and the testcase in the PR
passes. Yay.

As Daniel pointed out in the PR comments, the unfortunate side effect
of this approach is that we can no longer support instantiating
unordered containers with incomplete types. That's undefined
behaviour, but was allowed as QoI.  Conformance trumps QoI, I'm
afraid.  If someday we have noexcept move constructors for the
unordered containers we could allow incomplete types again.

        PR libstdc++/55043 (again)
        * include/bits/alloc_traits.h (allocator_traits::construct): Disable
        unless construction would be well-formed.
        (__allow_copy_cons, __check_copy_constructible): Define.
        * include/bits/unordered_map.h (__check_copy_constructible): Use as
        base class so copy constructor will be deleted if appropriate.
        (is_copy_constructible): Remove specialization.
        * include/bits/unordered_set.h: Likewise.
        * include/debug/unordered_map.h: Undo previous commit. Default copy
        and move constructors.
        * include/debug/unordered_set.h: Likewise.
        * include/profile/unordered_map.h: Undo previous commit.
        * include/profile/unordered_set.h: Likewise.
        * testsuite/23_containers/unordered_map/55043.cc: Fix test.
        * testsuite/23_containers/unordered_multimap/55043.cc: Likewise.
        * testsuite/23_containers/unordered_multiset/55043.cc: Likewise.
        * testsuite/23_containers/unordered_set/55043.cc: Likewise.
        * testsuite/23_containers/unordered_map/requirements/53339.cc: XFAIL,
        cannot support incomplete types.
        * testsuite/23_containers/unordered_multimap/requirements/53339.cc:
        Likewise.

Tested x86_86-linux, committed to trunk.

Attachment: patch.txt
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]