From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32351 invoked by alias); 31 Oct 2014 09:14:08 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 32317 invoked by uid 48); 31 Oct 2014 09:14:03 -0000 From: "adl at lrde dot epita.fr" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/63698] New: std::set leaks nodes on assignement Date: Fri, 31 Oct 2014 09:15:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 5.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: adl at lrde dot epita.fr X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-10/txt/msg02477.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63698 Bug ID: 63698 Summary: std::set leaks nodes on assignement Product: gcc Version: 5.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: adl at lrde dot epita.fr Compiling a project of mine with the latest gcc-snapshot distributed by Debian (g++ (Debian 20141016-1) 5.0.0 20141016 (experimental) [trunk revision 216349]), I started to get memory leaks. I reduced the problem to this small scenario: % cat foo.cc #include int main() { std::set v{2,1}; // The order of 2 and 1 is important. std::set w{6,5,4}; v = w; return v.size(); } % g++ -std=c++11 foo.cc -g -Wall % valgrind --leak-check=yes -q ./a.out ==30757== 40 bytes in 1 blocks are definitely lost in loss record 1 of 1 ==30757== at 0x4C29180: operator new(unsigned long) (vg_replace_malloc.c:324) ==30757== by 0x40277D: __gnu_cxx::new_allocator >::allocate(unsigned long, void const*) (new_allocator.h:104) ==30757== by 0x4026F8: std::allocator_traits > >::allocate(std::allocator >&, unsigned long) (alloc_traits.h:360) ==30757== by 0x402668: std::_Rb_tree, std::less, std::allocator >::_M_get_node() (stl_tree.h:485) ==30757== by 0x40238D: std::_Rb_tree_node* std::_Rb_tree, std::less, std::allocator >::_M_create_node(int const&) (stl_tree.h:539) ==30757== by 0x4021BE: std::_Rb_tree_node* std::_Rb_tree, std::less, std::allocator >::_Alloc_node::operator()(int const&) const (stl_tree.h:453) ==30757== by 0x401D82: std::_Rb_tree_iterator std::_Rb_tree, std::less, std::allocator >::_M_insert_, std::less, std::allocator >::_Alloc_node>(std::_Rb_tree_node_base*, std::_Rb_tree_node_base*, int const&, std::_Rb_tree, std::less, std::allocator >::_Alloc_node&) (stl_tree.h:1381) ==30757== by 0x401324: std::_Rb_tree_iterator std::_Rb_tree, std::less, std::allocator >::_M_insert_unique_, std::less, std::allocator >::_Alloc_node>(std::_Rb_tree_const_iterator, int const&, std::_Rb_tree, std::less, std::allocator >::_Alloc_node&) (stl_tree.h:1850) ==30757== by 0x400EF3: void std::_Rb_tree, std::less, std::allocator >::_M_insert_unique(int const*, int const*) (stl_tree.h:2096) ==30757== by 0x400D0B: std::set, std::allocator >::set(std::initializer_list, std::less const&, std::allocator const&) (stl_set.h:225) ==30757== by 0x400A6A: main (foo.cc:5) I suspect this is related to what was implemented for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=29988