Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Throw in destructor #1

Closed
claria opened this issue Nov 23, 2016 · 2 comments
Closed

Throw in destructor #1

claria opened this issue Nov 23, 2016 · 2 comments

Comments

@claria
Copy link

claria commented Nov 23, 2016

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

@mateidavid
Copy link
Owner

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

@mateidavid
Copy link
Owner

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

ferdymercury pushed a commit that referenced this issue Dec 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants