Skip to content

Conversation

@uditagarwal97
Copy link
Contributor

Coverity suggested to add these to follow the rule-of-three (https://en.cppreference.com/w/cpp/language/rule_of_three.html)

@uditagarwal97 uditagarwal97 self-assigned this Jul 10, 2025
@uditagarwal97 uditagarwal97 requested a review from a team as a code owner July 10, 2025 03:48
@uditagarwal97 uditagarwal97 requested a review from reble July 10, 2025 03:48
@uditagarwal97 uditagarwal97 requested a review from Copilot July 10, 2025 03:56
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR addresses a Coverity warning by explicitly defining special member functions to adhere to the C++ rule-of-three.

  • Adds a user-defined destructor to node_impl
  • Deletes the copy assignment operator in graph_mem_pool
  • Ensures graph_mem_pool cannot be copied or assigned

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
sycl/source/detail/graph/node_impl.hpp Introduces an empty destructor to follow rule-of-three
sycl/source/detail/graph/memory_pool.hpp Deletes the copy assignment operator for the memory pool
Comments suppressed due to low confidence (1)

sycl/source/detail/graph/node_impl.hpp:187

  • Defining an empty destructor suppresses the implicitly generated move operations and isn’t necessary here; consider using ~node_impl() = default; or omitting it entirely.
  ~node_impl() {}

return *this;
}

~node_impl() {}
Copy link

Copilot AI Jul 10, 2025

Choose a reason for hiding this comment

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

According to the rule-of-three, if you define a destructor, you should also explicitly define or delete the copy constructor and copy assignment operator; consider adding or deleting those to avoid accidental copying.

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We already have copy constructor and assignment operator defined.

}

/// Memory pool cannot be copied
graph_mem_pool(graph_mem_pool &) = delete;
Copy link

Copilot AI Jul 10, 2025

Choose a reason for hiding this comment

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

The copy constructor deletion uses a non-const reference, but the default copy constructor signature takes a const reference. As a result, the class remains copyable; change it to graph_mem_pool(const graph_mem_pool&) = delete;.

Suggested change
graph_mem_pool(graph_mem_pool &) = delete;
graph_mem_pool(const graph_mem_pool &) = delete;

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's orthogonal to the changes in this PR.

@uditagarwal97 uditagarwal97 merged commit 8640637 into sycl Jul 10, 2025
24 checks passed
@uditagarwal97 uditagarwal97 deleted the private/udit/cov_rule_of_3 branch July 10, 2025 13:56
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