[Bug libstdc++/46455] resource leaks due to missing destructors for mutexes and condvars

internet at 123gen dot com gcc-bugzilla@gcc.gnu.org
Wed Nov 17 07:42:00 GMT 2010


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

--- Comment #29 from Zouzou <internet at 123gen dot com> 2010-11-17 07:38:39 UTC ---
(In reply to comment #28)
> Created attachment 22427 [details]
> add destructors in <ext/concurrence.h>
> almost the same as the last patch but the destructor calls:
>   _S_destroy<__gthread_recursive_mutex_t>(&_M_mutex, 0);

different error this time:

In file included from
c:\mingw\bin\../lib/gcc/mingw32/4.5.0/include/c++/memory:78:0,
                 from test.cpp:15:
c:\mingw\bin\../lib/gcc/mingw32/4.5.0/include/c++/ext/concurrence.h: In static
member function 'static int __gnu_cxx::__recursive_mutex::_S_destroy(_Rm*,
typename __gnu_cxx::__recursive_mutex::_Detect_win32<_Rm, (& _Rm::
sema)>::type*) [with _Rm = __gthread_recursive_mutex_t, typename
__gnu_cxx::__recursive_mutex::_Detect_win32<_Rm, (& _Rm:: sema)>::type =
__gthread_mutex_t]':
c:\mingw\bin\../lib/gcc/mingw32/4.5.0/include/c++/ext/concurrence.h:224:54:  
instantiated from here
c:\mingw\bin\../lib/gcc/mingw32/4.5.0/include/c++/ext/concurrence.h:267:46:
error: void value not ignored as it ought to be

because __gthread_mutex_destroy returns void.

after changing the return types of the _S_destroy functions to void and
removing the "return" specifiers, the test case compiles and runs fine without
any leak.



More information about the Gcc-bugs mailing list