Fixed Compilation warnings | Issue #16336#16474
Merged
opencv-pushbot merged 1 commit intoopencv:3.4from Feb 1, 2020
gapry:issue_16336
Merged
Fixed Compilation warnings | Issue #16336#16474opencv-pushbot merged 1 commit intoopencv:3.4from gapry:issue_16336
opencv-pushbot merged 1 commit intoopencv:3.4from
gapry:issue_16336
Conversation
|
Sounds good ! |
gapry
commented
Jan 31, 2020
| double Point_<_Tp>::ddot(const Point_& pt) const | ||
| { | ||
| return (double)x*pt.x + (double)y*pt.y; | ||
| return (double)x*(double)(pt.x) + (double)y*(double)(pt.y); |
Contributor
Author
There was a problem hiding this comment.
Dear @bduclaux
Although the patch can fix the issue, the casting can achieve with static_cast.
Here, it's the code.
return static_cast<double>(x)*static_cast<double>(pt.x) +
static_cast<double>(y)*static_cast<double>(pt.y);
In C++ world, I think it's better. Do you agree ?
There was a problem hiding this comment.
Yes, static_cast is indeed much better.
Btw, there are tons of C-style cast in the code, and it will take months to fully check / rewrite them. Not a problem, unless the compiler emits warnings like above !
Thanks !
Member
|
Thank you for the contribution! This patch should go into 3.4 branch first. We will merge changes from 3.4 into master regularly (weekly/bi-weekly). So, please:
Note: no needs to re-open PR, apply changes "inplace". |
Contributor
Author
|
@alalek Thank you for your guide. I've done it. |
alalek
approved these changes
Feb 1, 2020
opencv-pushbot
pushed a commit
that referenced
this pull request
Feb 1, 2020
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.
This pullrequest changes
resolves #16336
Brief
The
main.cppwill occur the compilation warnings. The reason is at the modules/core/include/opencv2/core/types.hpp#L1218Detailed description
Assume a file calls
main.cppas belowIf the developer enables the
g++flags-Wall -Wdouble-promotionin the compilation,g++will output the following warning messages and generate a ELF file.If the developer enables the
g++flags-Wall -Werror -Wdouble-promotionin the compilation,g++will output the same warning messages but can't generate a ELF file.