-
Notifications
You must be signed in to change notification settings - Fork 915
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
Add cppcoreguidelines-*
to clang-tidy
#10174
Conversation
Codecov Report
@@ Coverage Diff @@
## branch-22.04 #10174 +/- ##
===============================================
Coverage ? 10.48%
===============================================
Files ? 122
Lines ? 20496
Branches ? 0
===============================================
Hits ? 2148
Misses ? 18348
Partials ? 0 Continue to review full report at Codecov.
|
@@ -223,7 +223,7 @@ std::unique_ptr<column> scatter( | |||
auto const num_rows = target.size(); | |||
if (num_rows == 0) { return cudf::empty_like(target); } | |||
|
|||
auto lv = static_cast<list_scalar const*>(&slr); | |||
auto lv = dynamic_cast<list_scalar const*>(&slr); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We aren't testing the results of this dynamic cast, so we should use references instead of pointers.
C.148: https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rh-ptr-cast
A failure to find the required class will cause
dynamic_cast
to return a null value, and de-referencing a null-valued pointer will lead to undefined behavior. Therefore the result of thedynamic_cast
should always be treated as if it might contain a null value, and tested.
Instead, dynamic_cast
to a reference type as recommended by C.147: https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#c147-use-dynamic_cast-to-a-reference-type-when-failure-to-find-the-required-class-is-considered-an-error
auto lv = dynamic_cast<list_scalar const*>(&slr); | |
auto lv = dynamic_cast<list_scalar const&>(slr); |
(and then change semantics below to reference .
instead of pointer ->
)
This PR has been labeled |
This is a follow up PR to: #9860
It should ideally be merged after: #10064