|
Boost : |
From: Ulrich Eckhardt (uli_at_[hidden])
Date: 2004-12-06 17:13:28
Cheers!
The code in question is this:
// boost/thread/exceptions.hpp
class thread_exception
{
...
const char* message() const;
};
// libs/thread/src/exceptions.cpp
std::string system_message(int sys_err_code){..}
const char* thread_exception::message() const
{
if (m_sys_err != 0)
return system_message(m_sys_err).c_str();
return what();
}
If message() is called and m_sys_err is set, it will return a pointer to
storage of a temporary, which is bad, as we all know.
I did some research on that, and I think this whole method can be removed
completely because:
- it is not decumented
- it is not used
- it never worked (probably, at least not with 1.32)
Further, one could then remove <string> from the includes in the header and
some more includes in the sourcefile.
An alternative approach would be to change the returntype to std::string, of
course, or (and I think that's an interesting alternative!) derive all those
classes from std::runtime_error, which can hold a std::string natively.
Uli
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk