Boost logo

Boost :

From: Ulrich Eckhardt (doomster_at_[hidden])
Date: 2007-02-10 03:35:18


(Sorry for the flashy topic, but I reported the bug already ages ago and I'm
slightly annoyed that it is still present. But hey, at least I could restrain
myself from using multiple exclamation marks.)

Hi!

If you compile libs/thread/src/exception.cpp, some compilers will warn you
about an unused variable (the argument to system_message()) when not
compiling for win32. Firstly, the fact that it doesn't use this variable but
uses errno directly to format a string is already broken, after all I
explicitly requested it to format a string for the given errorcode, not one
that happens to be in errno at that time (well, you could argue that that is
intended, after all the function is undocumented, but then you'd have to do
the same with win32 and use GetLastError() there).

Secondly, look at the way that function is used. It is used in
thread_exception::message() to format a std::string temporary and then return
the result of c_str() from a function! This returns a reference to a
temporary and the returned pointer can never be used! It can't work, simple
as that, it's broken and as far as I'm concerned it is even obviously so.

Solution: remove thread_exception::message(), no sane code could ever have
depended on that function anyway. Remove system_message() all along, it is
unused then. There is a slew of other code that is intended to access
strerror() (for POSIX) or FormatMessage() (for win32) in a portable way,
which is then also unused (of course, after all system_message() is a wrapper
around those and with it unused, those can go, too).

Please, please, please fix this! I have attached the patch for current CVS but
the same is already present in at least 1.33 and probably older versions,
too.

thank you

Uli




Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk