wiki:ReportingBugs

Version 1 (modified by Peter Dimov, 15 years ago) ( diff )

--

Reporting Bugs in Boost Components

The information on this page complements the bug reporting guidelines on the main site.

Reporting a Bug

Please 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.

The 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 here.

It'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.

Submitting a Unit Test

Creating an unit test is easy. We'll illustrate this with an example taken from the boost-users mailing list:

The following code using Lambda with vector iterators compiles without complaint:

vector<char> v;
find_if(v.begin(), v.end(), _1 == 'x');

Ditto for this code, which uses istream_iterators:

istream_iterator<char> b1(cin);
istream_iterator<char> e1;
find_if(b1, e1, _1 == 'x');

But the same code with istreambuf_iterators gets rejected:

istreambuf_iterator<char> b2(cin);
istreambuf_iterator<char> e2;
find_if(b2, e2, _1 == 'x');

Error messages from VC8 and gcc 4.1.1 are below. Am I doing something wrong, is there a bug in Lambda regarding istreambuf_iterators, or is this a restriction that I didn't see documented somewhere?

Here's the unit test that you, as the hypothetical reporter of the above bug, can submit as an attachment to the new ticket:

#include <boost/lambda/lambda.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <iterator>
#include <sstream>
#include <algorithm>

int main()
{
    using namespace boost::lambda;

    std::stringstream is( "ax2" );

    std::istreambuf_iterator<char> b2( is );
    std::istreambuf_iterator<char> e2;

    std::istreambuf_iterator<char> i = std::find_if( b2, e2, _1 == 'x' );

    BOOST_TEST( *i == 'x' );
    BOOST_TEST( std::distance( i, e2 ) == 2 );

    return boost::report_errors();
}

Note 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.

Thank you in advance for your bug reports and unit tests!

Note: See TracWiki for help on using the wiki.