From: John Maddock (John_Maddock_at_[hidden])
Date: 2001-05-02 06:09:57
I've recently rewritten the compressed pair test code, and come across some
problems with VC6. The problem occurs when one of the two types is an
empty class, and it's assigned to:
boost::compressed_pair<int, empty_class> cp;
cp.second() = some_empty_class_value;
The Borland and gcc compilers translate this correctly into a no-op, but
VC6 copies one byte from the address of "some_empty_class_value" to the
address returned from "cp.second()". But since the class is a zero sized
empty class, this actually has the result of overwriting the value of
This problem is not related to compressed_pair specifically, but will occur
whenever an assignment to an empty base class occurs. Worse the problem
seems only to occur for some compiler settings (debug - single threaded
builds seem to trigger it).
The problem can also be solved by adding a "do nothing" assignment operator
to the empty class, but this is not always possible (if the class comes
from a third party).
If anyone has any further insights into this, or any ideas about what we
should do with compressed_pair/VC6 combination I would welcome them.
- John Maddock
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk