Skip to content

Cut noexcept calculations in dynamic-inl.h - #1034

Closed
JoeLoser wants to merge 1 commit into
meta:masterfrom
JoeLoser:dynamic_noexcept_calculations
Closed

JoeLoser wants to merge 1 commit into
meta:masterfrom
JoeLoser:dynamic_noexcept_calculations

Conversation

@JoeLoser

Copy link
Copy Markdown
Contributor

Summary:

  • GCC 4.9 previously required marking TypeError special member
    functions with conditional noexcept.
  • GCC 5.1 does not have this issue. So, remove the conditional noexcept
    as they always evalaute to true in the existing code.

@yfeldblum yfeldblum left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Must also do .cpp.

@JoeLoser
JoeLoser force-pushed the dynamic_noexcept_calculations branch from 9b8d066 to 3475baa Compare February 27, 2019 06:01
@JoeLoser

Copy link
Copy Markdown
Contributor Author

Thanks, just fixed the corresponding .cpp file as well. Any particular reason all five special member functions aren't just =defaulted in dynamic-inl.h?

@yfeldblum

Copy link
Copy Markdown
Contributor

There was a reason which appears no longer to be relevant. This was to outline these functions to shrink the code size of throw TypeError(...); statements.

We are now using throw_exception<TypeError>(...); statements which already takes care of shrinking the code size, so the reason is no longer applicable.

So there should be no problem with declaring all of these as defaulted within the class body, which would automatically take care of finding the proper noexcept specification.

@JoeLoser
JoeLoser force-pushed the dynamic_noexcept_calculations branch from 3475baa to 54f7296 Compare February 27, 2019 15:02
@JoeLoser

Copy link
Copy Markdown
Contributor Author

Thanks for the explanation -- makes sense. I went ahead and just defaulted them in dynamic-inl.h.

Comment thread folly/dynamic-inl.h Resolved
Summary:
- GCC 4.9 previously required marking `TypeError` special member
  functions with conditional noexcept.
- GCC 5.1 does not have this issue, so defaulting them is sufficient. In
  fact, we can even let the compiler automatically generate these special
  member functions.
@JoeLoser
JoeLoser force-pushed the dynamic_noexcept_calculations branch from 54f7296 to 9698eef Compare February 28, 2019 02:28

@facebook-github-bot facebook-github-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@yfeldblum has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@yfeldblum

Copy link
Copy Markdown
Contributor

I am internally rewriting the commit message on this one before landing to reflect that this is now about de-outlining the special member functions.

@JoeLoser

JoeLoser commented Mar 1, 2019

Copy link
Copy Markdown
Contributor Author

Nice reword of the commit. Thanks for that and helping it land!

sandraiser pushed a commit to sandraiser/folly that referenced this pull request Mar 4, 2019
Summary:
The `TypeError` special member functions - copy and move constructors and assignment operators - were outlined to reduce inline code size of `throw TypeError(...);` statements. This is no longer necessary, since these sites have been replaced by `folly::throw_exception<TypeError>(...);` statements, which have minimal inline code size. As a benefit, the special member functions may all now be declared as defaulted within the class body, and the conditional `noexcept` calculations are no longer required to be written - the compiler will do them. (Note: as of the libstdc++ which ships with GCC 5, library exception special member functions are `noexcept`; previously, they are not.)

Pull Request resolved: meta#1034

Reviewed By: nbronson

Differential Revision: D14255166

Pulled By: yfeldblum

fbshipit-source-id: 2f795a2b937fee58f243a9d374fc01829c674fe6
@JoeLoser
JoeLoser deleted the dynamic_noexcept_calculations branch April 2, 2019 00:46
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.

3 participants