Uh oh!
There was an error while loading. Please reload this page.
Make ofstreams thow exception on write issues - #5255
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
6bc3616 to
a07cfa4Comparesamopolacek
commented
Jul 24, 2023
@chrchr-github can you please rerun the failed check? |
Uh oh!
There was an error while loading. Please reload this page.
samopolacek
commented
Jul 25, 2023
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. |
| { | ||
| assert(false); | ||
| // TODO report error |
| { | ||
| assert(false); | ||
| // TODO: Report error |
| { | ||
| assert(false); | ||
| // TODO report error |
firewave
commented
Jul 26, 2023
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 |
| if (!settings.outputFile.empty()) { | ||
| mErrorOutput = new std::ofstream(settings.outputFile); | ||
| mErrorOutput = new std::ofstream(); | ||
| mErrorOutput->exceptions(std::ios_base::failbit | std::ios_base::badbit); |
There was a problem hiding this comment.
Instead of repeating this pattern across we should introduce a helper function for this.
Uh oh!
There was an error while loading. Please reload this page.
7b16fdb to
b6282efCompareb6282ef to
729f929Comparefirewave
commented
May 27, 2024
We need to make sure we have tests for all these cases. That also needs to consider the issue addressed in cppcheck-opensource/simplecpp#339 i.e. |
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)?