I am not a boost iostreams expert... just a user. Having said that, if iostreams::read() can return -1 during the copy_impl then it looks like the original code could be a problem.
and it happens... it is indeed the test used to detect the end of the loop...
What was your test case to demonstrate this?
was something like short *data = new short[w*h]; for(int index_ligne=0;index_ligne<w;++index_ligne) { TIFFReadScanline(handler,data+(index_ligne*w), index_ligne); } ofstream file(filename.c_str(), ios_base::out|ios_base::binary); filtering_streambuf<output> out; out.push(bzip2_compressor()); out.push(file); basic_array_source<char> datastream((char*)data,w*h*sizeof(short)); boost::iostreams::copy(datastream, out); Regards, Mathieu -- http://matioupi.free.fr/