[Bug libstdc++/60308] New: [4.9 Regression] std::deque leaks memory
ppluzhnikov at google dot com
gcc-bugzilla@gcc.gnu.org
Fri Feb 21 23:31:00 GMT 2014
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 <deque>
int main()
{
for (int j = 0; j < 10; ++j)
{
const int ia[] = { 2, 3, 1, 4, 2, 1, 3, 0 };
std::deque<int> 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<int*>::allocate(unsigned
long, void const*) (/gcc-svn-install/include/c++/4.9.0/ext/new_allocator.h:104)
==24027== by 0x4011C3: std::_Deque_base<int, std::allocator<int>
>::_M_allocate_map(unsigned long)
(/gcc-svn-install/include/c++/4.9.0/bits/stl_deque.h:549)
==24027== by 0x400DDC: std::_Deque_base<int, std::allocator<int>
>::_M_initialize_map(unsigned long)
(/gcc-svn-install/include/c++/4.9.0/bits/stl_deque.h:594)
==24027== by 0x400B54: std::_Deque_base<int, std::allocator<int>
>::_Deque_base(std::allocator<int> const&)
(/gcc-svn-install/include/c++/4.9.0/bits/stl_deque.h:470)
==24027== by 0x400A27: std::deque<int, std::allocator<int> >::deque<int
const*>(int const*, int const*, std::allocator<int> 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)
More information about the Gcc-bugs
mailing list