Fixed undefined left shifting of negative number#23503
Merged
asmorkalov merged 1 commit intoopencv:4.xfrom Apr 20, 2023
Merged
Conversation
Added explicit cast to unsigned before doing the left shift. This was caught by UBSan which reported things like: drawing.cpp:361:22: runtime error: left shift of negative value -26214 drawing.cpp:383:22: runtime error: left shift of negative value -78642
Contributor
|
@asmorkalov , have we decided a policy regarding OpenCV/C++ type usage? Is opencv/modules/core/include/opencv2/core/hal/interface.h Lines 55 to 65 in b68aa12 |
Contributor
Author
|
According to cvdef.h "OpenCV 4.x+ requires enabled C++11 support". Are there c++11 compilers that don't support uint64_t? But I can change it if y'all want... |
Contributor
|
@mshabunin No. There was issue specific to libtiff. Nothing global for OpenCV. |
mshabunin
approved these changes
Apr 19, 2023
Contributor
mshabunin
left a comment
There was a problem hiding this comment.
Looks good for me, though I still think that it would be nicer to use uint64 instead of uint64_t for consistency with surrounding code, but it is not critical.
Merged
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Added explicit cast to unsigned before doing the left shift.
This was caught by UBSan which reported things like:
drawing.cpp:361:22: runtime error: left shift of negative value -26214
drawing.cpp:383:22: runtime error: left shift of negative value -78642