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]

[patch] Fix libstdc++/56112, inserting non-pairs into std::unordered_map


This is a much simpler fix than discussed in bugzilla, just forward to
_M_emplace() when inserting from a type that needs conversion to
value_type.  This also fixes the dangling reference problem as well as
the regression with calling insert() with convertible types.

       PR libstdc++/56112
       * include/bits/hashtable_policy.h (insert(_Pair&&)): Use _M_emplace
       to construct value_type explicitly before trying to extract the key.
       * testsuite/23_containers/unordered_map/cons/56112.cc: New.

Tested x86_64-linux, will commit to trunk tomorrow.

N.B. The dangling reference bug is present on the 4.6 and 4.7
branches, but not a regression.

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]