Boost C++ Libraries: Ticket #2649: iterator_range's assignment fires an assert when rhs is singular https://svn.boost.org/trac10/ticket/2649 <p> the following code will raise an assertion in debug builds: </p> <pre class="wiki">typedef boost::iterator_range&lt;std::string&gt; str_range_t; std::string eyal("eyal"); str_range_t eyal_range( eyal ), empty_range; //here it is... eyal_range = empty_range; </pre><p> the reason for the assert is an assert in iterator_range's begin/end methods, the assignment operator is doing something like </p> <pre class="wiki">this-&gt;m_begin = rhs.begin() </pre><p> which fails for debug builds when rhs is singular. </p> <p> a lot has been said about the decision to remove the singular member/concept from the library code, but I believe that assigning a singular range <strong>should not</strong> raise an assert. </p> <p> ps. I stumbled upon this bug after upgrading from 1.34 to 1.36, "I think this is a really nasty one because: <br /> </p> <ol><li>it denies me from using a very standard use case.<br /> </li><li>it simply crashes in release builds.<br /> </li><li>a massive behavior change for singular ranges which used to behave like empty ranges. while I agree that using iterators of a singular range is a bad idea, querying for its length is not.<br /> </li></ol><p> eyal. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/2649 Trac 1.4.3 Neil Groves Sat, 10 Apr 2010 15:02:05 GMT owner, status changed https://svn.boost.org/trac10/ticket/2649#comment:1 https://svn.boost.org/trac10/ticket/2649#comment:1 <ul> <li><strong>owner</strong> changed from <span class="trac-author">doug_gregor</span> to <span class="trac-author">Neil Groves</span> </li> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> </ul> Ticket Neil Groves Sat, 10 Apr 2010 15:06:19 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/2649#comment:2 https://svn.boost.org/trac10/ticket/2649#comment:2 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> The submitted code should never have compiled since iterator_range&lt;std::string&gt; is illegal. </p> <p> The newly merged <a class="missing wiki">RangeEx</a> into Range runs the following code without assertion in debug, or crash in release. </p> <p> I made the decision to remove the singularity concept from Boost.Range entirely. It is my opinion that singularity is a property of iterators and that it is not possible to usefully augment range to provide additional safety without removing the capability to support valid use-cases. </p> <p> #include &lt;string&gt; #include &lt;boost/range/iterator.hpp&gt; #include &lt;boost/range/sub_range.hpp&gt; </p> <p> typedef boost::sub_range&lt;std::string&gt; str_range_t; </p> <p> int main(int argc, const char* argv[]) { </p> <blockquote> <p> std::string eyal("eyal"); str_range_t eyal_range( eyal ), empty_range; </p> </blockquote> <blockquote> <p> eyal_range = empty_range; </p> </blockquote> <blockquote> <p> return 0; </p> </blockquote> <p> } </p> Ticket Neil Groves Sat, 10 Apr 2010 15:07:20 GMT milestone changed https://svn.boost.org/trac10/ticket/2649#comment:3 https://svn.boost.org/trac10/ticket/2649#comment:3 <ul> <li><strong>milestone</strong> <span class="trac-field-old">Boost 1.38.0</span> → <span class="trac-field-new">Boost 1.43.0</span> </li> </ul> Ticket