Exception thrown in function declared not to throw exceptions.
Codacy detected an issue:
Message: Exception thrown in function declared not to throw exceptions.
Occurred on:
- Commit: 6aa546fc427871e2e3bbd99bc40b4d5d790c3ef7
- File: include/CLI/App.hpp
- LineNum: 2155
- Code:
for(const App_p &com : subcommands_) {
Currently on:
- Commit: cb72d1f2bbac2f5b5d58f07a6ffc1750adb6d6d9
- File: include/CLI/App.hpp
- LineNum: 2617
@phlptp I think this was created when some noexcept versions were added, but not everywhere.
would we need to make a lot of the underlying functions noexcept as well?
We'd need to duplicate quite a bit, I think. If this is just a static issue (that is, if it really can't throw an exception here at runtime), it's likely not worth it? But it's very much a problem if it's possible to trigger an exception here.
On several of the subfunction calls the exception path is std::string not being able to be allocated. Which as far as I am concerned if that occurs the program should terminate, that is not recoverable. For example someone tries with an incredibly long string. The only other path I see would only be if some other iterators are out of order and we control, so if that were the case pretty sure we would have found it already.
I would say in other projects unless I have a real need to be pedantic I have ignored the fact that the constructor for std::string can throw