Fix for C4146 Error in CPUNegElementKernel with Unsigned Types #6534
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.
Fix the compile error.
UnaryEWCPU.cpp(100): error C4146: unary minus operator applied to unsigned type, result still unsigned
Type
Motivation and Context
Checklist:
python util/check_style.py --apply
to apply Open3D code styleto my code.
updated accordingly.
results (e.g. screenshots or numbers) here.
Description
The CPUNegElementKernel function in UnaryEWCPU.cpp triggers a compilation error (C4146) when instantiated with an unsigned scalar_t type.
This error is caused by applying the unary minus operator to an unsigned type, where the result remains unsigned, leading to undefined behavior.
I am tyring to write port for vpckg.
I got C4146 error during the compilations.
manual build option( other options are default)
OS: windows 11
Compiler:MSVC (visuals studio 2022 17.8)