CLI11 icon indicating copy to clipboard operation
CLI11 copied to clipboard

Exception thrown in function declared not to throw exceptions.

Open henryiii opened this issue 4 years ago • 4 comments

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:

henryiii avatar Jul 19 '21 20:07 henryiii

@phlptp I think this was created when some noexcept versions were added, but not everywhere.

henryiii avatar Jul 19 '21 20:07 henryiii

would we need to make a lot of the underlying functions noexcept as well?

phlptp avatar Jul 19 '21 22:07 phlptp

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.

henryiii avatar Jul 19 '21 22:07 henryiii

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

phlptp avatar Jul 19 '21 23:07 phlptp