Changes between Initial Version and Version 1 of ReportingBugs


Ignore:
Timestamp:
Jul 27, 2007, 12:26:56 AM (15 years ago)
Author:
Peter Dimov
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • ReportingBugs

    v1 v1  
     1= Reporting Bugs in Boost Components =
     2
     3The information on this page complements [http://www.boost.org/more/bugs.htm the bug reporting guidelines on the main site].
     4
     5== Reporting a Bug ==
     6
     7Please [http://svn.boost.org/trac/boost/newticket enter a new Trac ticket] for the bug. Be sure to set the Component field properly. You can also report the bug on one of the mailing lists, referencing the ticket number.
     8
     9The maintainers of the Boost component affected by the bug will appreciate if you already have an idea how to fix it. It's best if you submit a patch, as explained [http://www.boost.org/more/bugs.htm here].
     10
     11It's even more helpful if you submit a new unit test instead of, or in addition to, your patch. This guarantees that the bug stays fixed.
     12
     13== Submitting a Unit Test ==
     14
     15Creating an unit test is easy. We'll illustrate this with an [http://lists.boost.org/boost-users/2007/07/29648.php example] taken from the [http://lists.boost.org/boost-users/ boost-users] mailing list:
     16
     17  The following code using Lambda with vector iterators compiles without complaint:
     18
     19  {{{
     20  vector<char> v;
     21  find_if(v.begin(), v.end(), _1 == 'x');
     22  }}}
     23
     24  Ditto for this code, which uses istream_iterators:
     25
     26  {{{
     27  istream_iterator<char> b1(cin);
     28  istream_iterator<char> e1;
     29  find_if(b1, e1, _1 == 'x');
     30  }}}
     31
     32  But the same code with istreambuf_iterators gets rejected:
     33
     34  {{{
     35  istreambuf_iterator<char> b2(cin);
     36  istreambuf_iterator<char> e2;
     37  find_if(b2, e2, _1 == 'x');
     38  }}}
     39
     40  Error messages from VC8 and gcc 4.1.1 are below. Am I doing something wrong, is
     41  there a bug in Lambda regarding istreambuf_iterators, or is this a restriction
     42  that I didn't see documented somewhere?
     43
     44Here's the unit test that you, as the hypothetical reporter of the above bug, can submit as an attachment to the new ticket:
     45
     46{{{
     47#include <boost/lambda/lambda.hpp>
     48#include <boost/detail/lightweight_test.hpp>
     49#include <iterator>
     50#include <sstream>
     51#include <algorithm>
     52
     53int main()
     54{
     55    using namespace boost::lambda;
     56
     57    std::stringstream is( "ax2" );
     58
     59    std::istreambuf_iterator<char> b2( is );
     60    std::istreambuf_iterator<char> e2;
     61
     62    std::istreambuf_iterator<char> i = std::find_if( b2, e2, _1 == 'x' );
     63
     64    BOOST_TEST( *i == 'x' );
     65    BOOST_TEST( std::distance( i, e2 ) == 2 );
     66
     67    return boost::report_errors();
     68}
     69}}}
     70
     71Note that even though the bug report only states that the code doesn't compile, the unit test actually tests whether the code, when compiled, actually does what it's expected to do. This may seem trivial, but it does help. Be sure to not forget the `return boost::report_errors()` statement at the end of `main`.
     72
     73Thank you in advance for your bug reports and unit tests!