Boost logo

Boost :

From: Jeremy Siek (jsiek_at_[hidden])
Date: 2001-05-05 11:27:26


I think I ran into this problem before... I had put a comment into the
code for the assignment and/or copy constructor with a brief description.
I had used the same workaround that you describe below.

On Wed, 2 May 2001, John Maddock wrote:

John_M> boosters,
John_M>
John_M> I've recently rewritten the compressed pair test code, and come across some
John_M> problems with VC6. The problem occurs when one of the two types is an
John_M> empty class, and it's assigned to:
John_M>
John_M> boost::compressed_pair<int, empty_class> cp;
John_M> cp.second() = some_empty_class_value;
John_M>
John_M> The Borland and gcc compilers translate this correctly into a no-op, but
John_M> VC6 copies one byte from the address of "some_empty_class_value" to the
John_M> address returned from "cp.second()". But since the class is a zero sized
John_M> empty class, this actually has the result of overwriting the value of
John_M> cp.first() !
John_M>
John_M> This problem is not related to compressed_pair specifically, but will occur
John_M> whenever an assignment to an empty base class occurs. Worse the problem
John_M> seems only to occur for some compiler settings (debug - single threaded
John_M> builds seem to trigger it).
John_M>
John_M> The problem can also be solved by adding a "do nothing" assignment operator
John_M> to the empty class, but this is not always possible (if the class comes
John_M> from a third party).
John_M>
John_M> If anyone has any further insights into this, or any ideas about what we
John_M> should do with compressed_pair/VC6 combination I would welcome them.
John_M>
John_M> - John Maddock
John_M> http://ourworld.compuserve.com/homepages/john_maddock/
John_M>
John_M> To unsubscribe, send email to: <mailto:boost-unsubscribe_at_[hidden]>
John_M>
John_M>
John_M> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
John_M>
John_M>
John_M>

----------------------------------------------------------------------
 Jeremy Siek www: http://www.lsc.nd.edu/~jsiek/
 Ph.D. Candidate email: jsiek_at_[hidden]
 Univ. of Notre Dame work phone: (219) 631-3906
----------------------------------------------------------------------


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