I used  set <string> ss 
as a containtor for a list of unique, ordered strings. However, program
reports segmentation error when trying to allocate a block of memory. 

I have used libcwd to debug the memory allocation, the libcwd detected
memory leaks:
+-----------------------------------------------------------------------------+
|MALLOC  : operator new (size = 1088) = 0x83a2a18                             |
|libstdc++.so.5:_ZNSt24__default_alloc_templateILb1ELi0EE14_S_chunk_allocEjRi]|
|  * WARNING : Memory leak detected!                                          |
|    *           0x83a2a18 std::__default_alloc_template<true,                |
|    *           0>::_S_chunk_alloc(unsigned int, int&) <unknown type>;  (sz  |
|    *           = 1088)                                                      |
+-----------------------------------------------------------------------------+

Memory leak problem solved by changing 
Set <string> ss  ==>   set <char*> ss
However, I'm not sure if this only solves the problem temporary, since
set <string> does not result in memory leaks in most cases. 

Program was compiled by  
g++ -g3 src.cpp  -o prog -lm 
~


-- 
           Summary: memory leak with  libstdc++  set <string>
           Product: gcc
           Version: 3.3.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: nanjiang dot shu at gmail dot com
 GCC build triplet: i586-mandrake-linux-gnu
  GCC host triplet: i686-mandrake-linux-gnu
GCC target triplet: i586-mandrake-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27615

Reply via email to