cppcheck icon indicating copy to clipboard operation
cppcheck copied to clipboard

Make ofstreams thow exception on write issues

Open samopolacek opened this issue 2 years ago • 4 comments

This is related to #5254.

I have observed that if non-existent --cppcheck-build-dir is used, all file writes silently fail.

Should we enable exceptions on std::ofstream(s)?

samopolacek avatar Jul 20 '23 14:07 samopolacek

@chrchr-github can you please rerun the failed check?

samopolacek avatar Jul 24 '23 07:07 samopolacek

Ready for review. A bit bloaty, not sure if all the asserts are needed, maybe I am too defensive. Please note that there are a few TODOs I would like to get reviewed.

samopolacek avatar Jul 25 '23 19:07 samopolacek

In some cases this is by design and would cause existing installations to fail. So this might require a soft deprecation with introducing a warning first in some cases.

Also we should add cli Python tests for each of these to make sure they fail as expected.

firewave avatar Jul 26 '23 18:07 firewave

We need to make sure we have tests for all these cases. That also needs to consider the issue addressed in https://github.com/danmar/simplecpp/pull/339 i.e. fstream can successfully open directories but just not read from them.

firewave avatar May 27 '24 12:05 firewave