In Wesnoth 0.9.1, checksumstream is derived from std::basic_ostream<char>, and has a checksumstreambuf sbuf; as a member, where checksumstreambuf is derived from std::basic_streambuf<char>

Its constructor looks like this:

checksumstream::checksumstream() : std::basic_ostream<char>(&sbuf)
{
}

This is a problem because bases are constructed before members. So, at the time the std::basic_ostream<char> constructor is run, sbuf hasn't been constructed, and std::basic_ostream<char> is given an address to an invalid object.

This causes a crash in VC++6 with STLPort.

I am hacking around this so I can make a working Windows release of 0.9.1 by defining checksumstream like this:

class checksumstream : private checksumstreambuf, public std::basic_ostream<char>
{
public:
   checksumstream();
   unsigned long checksum();
private:
   checksumstreambuf& sbuf;
};

and its constructor like this:

checksumstream::checksumstream() : std::basic_ostream<char>(this), sbuf(*this)
{
}

However it would be appreciated if the person who wrote this class apply a permanent fix.

David


Reply via email to