-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pcl::PCLException shall have a nothrow copy constructor and a nothrow copy assigment operator #1105
Comments
Could you please elaborate a bit more on your proposals?
Why? What (and how much) can we gain from this?
How is this better than currently used
Have no clue actually, but these function do exist and may be used by existing user code. Removing them will break API with no added benefit.
From what I see, they do return the same message. As per the title of the issue, I think |
The 'problem' is that the compilers may generate code which copies the exception after throwing that exception. (and before catching) The std::string's copy constructor and assignment operator may throw (because of the heap allocation), so the same functions in PCLException may throw too. Reference counting: One simpler solution: |
It's not a big issue, because today's compilers don't copy exceptions (clang 3.4, gcc 4.9, vs2013), except when the user want (eg throw e;). But older compilers might copy. |
+1 The |
It is not a problem if an exception's constructor throws. The constructed exception is lost (it never existed) and the new one is handled instead. So calling detailedMessage in the constructor is not a problem. |
But this is misleading, isn't it? Instead of getting a Still, I am not sure I understand everything you propose. Changing |
Yes, it is misleading, but it is better than a pure std::terminate call. The changes: |
Looks good to me! Just add a space in line 102 ;) |
Fixed in #1119 |
I think the PCLException class should
What do you think?
Does it makes sense to call the getLineNumber(), getFunctionName(), getFileName() on an exception?
The what() and the detailedMessage() should return the same message?
The text was updated successfully, but these errors were encountered: