[llvm-bugs] [Bug 29001] New: operator= for std::map violates the standard

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Aug 16 05:36:53 PDT 2016


https://llvm.org/bugs/show_bug.cgi?id=29001

            Bug ID: 29001
           Summary: operator= for std::map violates the standard
           Product: libc++
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: furkanusta17 at gmail.com
                CC: llvm-bugs at lists.llvm.org, mclow.lists at gmail.com
    Classification: Unclassified

std::map's operator= violates the standard when
propagate_on_container_copy_assignment is true and allocators do not compare
equal

Code: http://melpon.org/wandbox/permlink/uPR3u5fYkUx2In4k

I couldn't find where in the standard it states but in cppreference operator=
for std::map says that

If
std::allocator_traits<allocator_type>::propagate_on_container_copy_assignment()
is true, the target allocator is replaced by a copy of the source allocator. If
the target and the source allocators do not compare equal, the target (*this)
allocator is used to deallocate the memory, then other's allocator is used to
allocate it before copying the elements.


Although in the example it doesn't even allocate, I guess it is because there
is 
some sort of caching system, in the code it does

__copy_assign_alloc(__t);
__assign_multi(__t.begin(), __t.end()); 

Then caches the nodes to be deleted in __assign_multi, but allocator already
changes in __copy_assign_alloc

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160816/b71badac/attachment-0001.html>


More information about the llvm-bugs mailing list