If the output buffer given to the compress() call here https://github.com/mapbox/gzip-hpp/blob/master/include/gzip/compress.hpp#L27 already contains some data (which might make sense if you want to compress several things one after the other before writing them out in one go), the code below (https://github.com/mapbox/gzip-hpp/blob/master/include/gzip/compress.hpp#L82-L89) will not do the right thing.