mateidavid/zstr

Throw in destructor

Closed this issue · 2 comments

Hi,

when i compile this library with a recent gcc (6.2.1) i get the following warning:

zstr.hpp: In destructor ‘virtual zstr::ostreambuf::~ostreambuf( ’:
zstr.hpp:271:79: warning: throw will always call terminate() [-Wterminate]
if (sync() != 0) throw Exception("~ostreambuf(): error in sink stream");

Cheers,
Georg

Thanks, I've been aware of the problem. I see 2 possible alternatives: (i) not signalling an output buffer flush error at all from the destructor, or (ii) exit or std::terminate. I just haven't decided which one would be better, they both seem quite bad. I'm inclining towards (i) though, for the reasons explained here:
http://stackoverflow.com/a/130123/717706

I decided to remove the throw and hide the error, mirroring the behaviour in std::basic_filebuf::~basic_filebuf().