-
Notifications
You must be signed in to change notification settings - Fork 255
Compile RMM with -Wsign-conversion
#2308
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
rapids-bot
merged 13 commits into
rapidsai:main
from
Matt711:fix-sign-conversion-warnings
Mar 17, 2026
Merged
Changes from 1 commit
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
d23657c
Fix -Wsign-conversion errors in format.hpp and stream_ordered_memory_…
Matt711 93b5823
Use C++17-compatible safe_cast implementation
Matt711 5e327b5
Use static_cast to fix -Wsign-conversion in stream_ordered_memory_res…
Matt711 d001da1
Add -Wsign-conversion to build flags and fix all violations
Matt711 209cd8e
lint
Matt711 c328dd8
Merge remote-tracking branch 'upstream/main' into fix-sign-conversion…
bdice b4bced1
Apply suggestion from @coderabbitai[bot]
bdice 0a1e5d4
Update vendored rapidcsv.h from version 6.10 to version 8.92
bdice 065afac
Fix -Wsign-conversion warnings in benchmark sources
bdice 723c8bc
Merge branch 'fix-sign-conversion-warnings' of https://github.com/Mat…
bdice 1817b00
Merge remote-tracking branch 'upstream/main' into fix-sign-conversion…
bdice 94224a4
Remove custom CMake flags from tests
bdice bba47b7
Fix -Wsign-conversion warnings in device_uvector_bench.cu
bdice File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| /* | ||
| * SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION. | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <rmm/detail/error.hpp> | ||
|
|
||
| #include <type_traits> | ||
|
|
||
| namespace rmm::detail { | ||
|
|
||
| /** | ||
| * @brief Checked narrowing/sign-converting cast. | ||
| * | ||
| * Casts `value` to type `To`, asserting at runtime that the value is | ||
| * representable in `To`. In release builds the assertion compiles away when | ||
| * the compiler can prove it is always true. | ||
| */ | ||
| template <typename To, typename From> | ||
| [[nodiscard]] constexpr To safe_cast(From value) | ||
| { | ||
| static_assert(std::is_integral_v<From> && std::is_integral_v<To>, | ||
| "safe_cast is only defined for integral types"); | ||
| if constexpr (std::is_signed_v<From> && std::is_unsigned_v<To>) { | ||
| RMM_EXPECTS(value >= From{0}, "safe_cast: negative value cannot be represented as unsigned"); | ||
| } | ||
| return static_cast<To>(value); | ||
| } | ||
|
|
||
| } // namespace rmm::detail |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.