Skip to content

Conversation

@ihsinme
Copy link
Contributor

@ihsinme ihsinme commented Jun 15, 2021

Good day.
in this request I am looking for errors when using exceptions.
I have identified 2 main areas:

  1. the possibility of generating an exception in the body of the distructor, without full processing inside.
  2. creating an exception object without generating the last one.

Regarding fixes in real software, my proposal is pending, but I plan to continue searching.
assimp/assimp#3954

@ihsinme ihsinme requested a review from a team as a code owner June 15, 2021 13:49
not fc instanceof ConstructorDirectInit and
not fc.getEnclosingStmt() instanceof DeclStmt and
not fc instanceof ConstructorDelegationInit and
msg = "This object does not generate an exception."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This case looks interesting. Can you give an example (preferably a test case) demonstrating what it is trying to catch?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I am looking for objects of type std :: exception that do not throw exceptions.

a basic example can be seen in PR. I will try to make a test case a little later.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, broadly, it's looking for cases where a std::exception object is created but not as part of a throw? e.g. the author writes

std::bad_alloc();

when they meant to write:

throw std::bad_alloc();

@ihsinme
Copy link
Contributor Author

ihsinme commented Jun 21, 2021

Good day.
Changed description and request a bit.
so as not to disagree with the existing request.

<li>
CERT CPP Coding Standard:
<a href="https://wiki.sei.cmu.edu/confluence/display/cplusplus/DCL57-CPP.+Do+not+let+exceptions+escape+from+destructors+or+deallocation+functions">DCL57-CPP. Do not let exceptions escape from destructors or deallocation functions</a>.
<a href="https://wiki.sei.cmu.edu/confluence/display/java/ERR00-J.+Do+not+suppress+or+ignore+checked+exceptions">ERR00-J. Do not suppress or ignore checked exceptions</a>.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This page is about the Java language. Please would you replace it with an equivalent C/C++ link?

not ts.getACatchClause().isEmpty()
) and
msg = "This distructor contains exeption no wrapped to try..catch blocks"
msg = "Exception inside this function requires more handling."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this is now looking for a throw statement inside a called function, that is not caught/handled inside that function. This seems like something that normal correct code would be doing fairly frequently, for example a function that's supposed to access a file might reasonably throw an exception if that file doesn't exist.

@ihsinme
Copy link
Contributor Author

ihsinme commented Jun 22, 2021

it looks stupid. (
probably the best solution, in a situation where you missed an existing request, is to close the PR and return with a new verified request.

sorry for wasting time.

@ihsinme ihsinme closed this Jun 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants