Skip to content

CXX-3043 Address Coverity warnings for Ro3/Ro5 violations #1142

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

Merged
merged 2 commits into from
Jun 4, 2024

Conversation

eramongodb
Copy link
Contributor

Resolves CXX-3043. Verified by this patch.

This PR explicitly defaults or deletes special member functions (SMFs) which are currently implicitly defaulted or deleted, in accordance with the Rule of All or Nothing. This addresses multiple Coverity issues as well as a few -Wdeprecated-copy-with-* Clang warnings (depending on implicit default of copy SMFs given a user-declared dtor, copy ctor, or copy assign op).

This PR should NOT change either the API or the ABI. This PR should NOT change the behavior at either compile-time or runtime, with exactly one exception: index_model's explicitly deleted copy assignment operator is now defaulted. It is unclear why this function was deleted when all other SMFs are (out-of-line) defaulted. This change is not expected to break user code.

Some additional notes worth mentioning:

  • = default within class definition does not require (BSONCXX|MONGOCXX)_INLINE per VISIBILITY_INLINES_HIDDEN=ON, as class member functions defined within the class definition are implicitly inline (even with = default), so all instances of such redundant inline macro usage are removed for consistency.
  • The quoted bug with inline dtor default definition behavior for VS2015 in concatenate.hpp is no longer an issue (AFAICT).
  • Removed redundant explicit noexcept for defaulted/deleted SMFs. This is only applicable to SFMs that are defaulted on first declaration, thus SMFs defaulted out-of-line still require explicit noexcept.
  • Deleted SMFs that are unnecessary/unused internally (i.e. impl classes).
  • Inconsistencies in inline vs. out-of-line SMF defaults are expected to be resolved in the near future via v1 namespace interfaces. This PR favors avoiding the introduction of new ABI symbols; if consistency is preferred, new (explicitly defaulted) SMFs can be defined out-of-line instead (this can also be done in a followup PR).

@eramongodb eramongodb requested a review from kevinAlbs June 3, 2024 17:47
@eramongodb eramongodb self-assigned this Jun 3, 2024
@kevinAlbs kevinAlbs requested a review from rcsanchez97 June 3, 2024 20:05
Copy link
Contributor

@rcsanchez97 rcsanchez97 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Collaborator

@kevinAlbs kevinAlbs left a comment

Choose a reason for hiding this comment

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

LGTM with one comment addressed.

@@ -42,6 +42,13 @@ class heartbeat_started_event {
///
~heartbeat_started_event();

heartbeat_started_event(heartbeat_started_event&&) = default;
MONGOCXX_INLINE heartbeat_started_event& operator=(heartbeat_started_event&&) noexcept =
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
MONGOCXX_INLINE heartbeat_started_event& operator=(heartbeat_started_event&&) noexcept =
heartbeat_started_event& operator=(heartbeat_started_event&&) noexcept =

@eramongodb eramongodb merged commit 04e31f8 into mongodb:master Jun 4, 2024
1 check was pending
@eramongodb eramongodb deleted the cxx-3043 branch June 4, 2024 20:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants