Ticket #3822 (closed Bugs: fixed)
boost/asio/buffer.hpp MSVC workaround is inaccurately targeted
|Reported by:||Stephan T. Lavavej <stl@…>||Owned by:||chris_kohlhoff|
This was reported to Microsoft as a bug in VC10 Beta 2 (see http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=522096 ), but is actually a bug in Boost.Asio, caused by an inaccurately targeted workaround for a bug in VC8!
The offending code is in boost/asio/buffer.hpp :
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
MSVC's string iterator checking may crash in a std::string::iterator object's destructor when the iterator points to an already-destroyed std::string object, unless the iterator is cleared first. iter_ = Iterator();
#endif BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
The bug mentioned by the comment affected only VC8 (_MSC_VER == 1400). VC9 RTM and later are unaffected, as I fixed this bug in VC9 RTM. Therefore, the BOOST_WORKAROUND should check for == 1400, not >= 1400.
(This workaround uses a singular iterator as the source of an assignment, which triggers undefined behavior. This crashes VC10 Beta 2 due to the extensive changes we made in the STL. It should probably trigger an assert dialog - I've made a note to myself about that. But in any event, a conformant implementation is allowed to explode when it sees this. I believe the workaround is correct for VC8, and it appears to be harmless for VC9, but restricting it to VC8 would be ideal.)