From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2901 invoked by alias); 21 Feb 2014 23:31:59 -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 2878 invoked by uid 48); 21 Feb 2014 23:31:55 -0000 From: "ppluzhnikov at google dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/60308] New: [4.9 Regression] std::deque leaks memory Date: Fri, 21 Feb 2014 23:31: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: unknown X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: ppluzhnikov at google dot com 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-02/txt/msg02317.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60308 Bug ID: 60308 Summary: [4.9 Regression] std::deque leaks memory Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: ppluzhnikov at google dot com std::deque currently leaks memory. Test case: #include int main() { for (int j = 0; j < 10; ++j) { const int ia[] = { 2, 3, 1, 4, 2, 1, 3, 0 }; std::deque d(ia, ia + sizeof (ia) / sizeof (ia[0])); } } Using current trunk: g++ (GCC) 4.9.0 20140221 (experimental) g++ -g t.cc Valgrind says: valgrind --leak-check=yes ./a.out ==24027== HEAP SUMMARY: ==24027== in use at exit: 5,760 bytes in 20 blocks ==24027== total heap usage: 40 allocs, 20 frees, 11,520 bytes allocated ==24027== ==24027== 5,760 (640 direct, 5,120 indirect) bytes in 10 blocks are definitely lost in loss record 2 of 2 ==24027== at 0x402F2A9: operator new(unsigned long) (valgrind/coregrind/m_replacemalloc/vg_replace_malloc.c:298) ==24027== by 0x401531: __gnu_cxx::new_allocator::allocate(unsigned long, void const*) (/gcc-svn-install/include/c++/4.9.0/ext/new_allocator.h:104) ==24027== by 0x4011C3: std::_Deque_base >::_M_allocate_map(unsigned long) (/gcc-svn-install/include/c++/4.9.0/bits/stl_deque.h:549) ==24027== by 0x400DDC: std::_Deque_base >::_M_initialize_map(unsigned long) (/gcc-svn-install/include/c++/4.9.0/bits/stl_deque.h:594) ==24027== by 0x400B54: std::_Deque_base >::_Deque_base(std::allocator const&) (/gcc-svn-install/include/c++/4.9.0/bits/stl_deque.h:470) ==24027== by 0x400A27: std::deque >::deque(int const*, int const*, std::allocator const&) (/gcc-svn-install/include/c++/4.9.0/bits/stl_deque.h:909) ==24027== by 0x40094C: main (/tmp/t.cc:8) ==24027== ==24027== LEAK SUMMARY: ==24027== definitely lost: 640 bytes in 10 blocks ==24027== indirectly lost: 5,120 bytes in 10 blocks ==24027== possibly lost: 0 bytes in 0 blocks ==24027== still reachable: 0 bytes in 0 blocks ==24027== suppressed: 0 bytes in 0 blocks Same test shows no leaks with gcc-4.8: g++ (GCC) 4.8.3 20140109 (prerelease)