This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: New warnings in libstdc++-v3 since 2004-01-05
- From: Gabriel Dos Reis <gdr at integrable-solutions dot net>
- To: Andreas Jaeger <aj at suse dot de>
- Cc: libstdc <libstdc++ at gcc dot gnu dot org>
- Date: 08 Jan 2005 17:26:37 +0100
- Subject: Re: New warnings in libstdc++-v3 since 2004-01-05
- Organization: Integrable Solutions
- References: <m3hdlsz5uu.fsf@gromit.moeb>
Andreas Jaeger <aj@suse.de> writes:
| I see the following new warnings when compiling GCC CVS on different
| Linux platforms:
| ../../../../libstdc++-v3/src/bitmap_allocator.cc: In member function 'size_t* __gnu_cxx::free_list::_M_
| get(size_t)':
| ../../../../libstdc++-v3/src/bitmap_allocator.cc:110: warning: control reaches end of non-void function
|
| ../../../../libstdc++-v3/testsuite/testsuite_abi.cc: In function ‘symbol& get_symbol(const std::string&, const symbols&)’:
| ../../../../libstdc++-v3/testsuite/testsuite_abi.cc:268: warning: control reaches end of non-void function
|
| What is the best way to fix this?
fix the compiler regression.
|
| Should we add to include/bits/functexcept.h some
| __attribute__((noreturn)) ?
No!!! The function does return!
This is a compiler regression. The body of the function is:
_M_get(size_t __sz) throw(std::bad_alloc)
{
#if defined __GTHREADS
_Lock __bfl_lock(&_S_bfl_mutex);
__bfl_lock._M_lock();
#endif
iterator __temp =
__gnu_cxx::balloc::__lower_bound
(_S_free_list.begin(), _S_free_list.end(),
__sz, _LT_pointer_compare());
if (__temp == _S_free_list.end() || !_M_should_i_give(**__temp,
__sz))
{
// We release the lock here, because operator new is
// guaranteed to be thread-safe by the underlying
// implementation.
#if defined __GTHREADS
__bfl_lock._M_unlock();
#endif
// Try twice to get the memory: once directly, and the 2nd
// time after clearing the free list. If both fail, then
// throw std::bad_alloc().
int __ctr = 2;
while (__ctr)
{
size_t* __ret = 0;
--__ctr;
try
{
__ret = reinterpret_cast<size_t*>
(::operator new(__sz + sizeof(size_t)));
}
catch(...)
{
this->_M_clear();
}
if (!__ret)
continue;
*__ret = __sz;
return __ret + 1;
}
std::__throw_bad_alloc();
}
else
{
size_t* __ret = *__temp;
_S_free_list.erase(__temp);
#if defined __GTHREADS
__bfl_lock._M_unlock();
#endif
return __ret + 1;
}
}
In the if-part, the function either (a) returns, from the while-loop;
or (b) throws. In the else-part, it does return.
Please, fill a C++ front-end PR.
-- Gaby
PS: I would not mind removing the exception-specification from
the function.