Skip to content

build: fix warning in Clang 10#24664

Merged
opencv-pushbot merged 1 commit intoopencv:4.xfrom
tomoaki0705:warning_fix_clang
Dec 8, 2023
Merged

build: fix warning in Clang 10#24664
opencv-pushbot merged 1 commit intoopencv:4.xfrom
tomoaki0705:warning_fix_clang

Conversation

@tomoaki0705
Copy link
Copy Markdown
Contributor

I had a chance to build OpenCV with clang 10.
I found 5 lines of warnings and I think it's worth to prevent it.

/opencv/3rdparty/carotene/src/div.cpp:160:19: warning: implicit conversion from 'int' to 'float' changes value from 2147483647 to 2147483648 [-Wi[0/1875]int-float-conversion]
         (scale * std::numeric_limits<T>::max()) <  1.0f &&
                ~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opencv/3rdparty/carotene/src/div.cpp:453:5: note: in instantiation of function template specialization 'carotene_o4t::(anonymous namespace)::div<int>' requested here
    div<s32>(size, src0Base, src0Stride, src1Base, src1Stride, dstBase, dstStride, scale, cpolicy);
    ^
/opencv/3rdparty/carotene/src/div.cpp:161:19: warning: implicit conversion from 'int' to 'float' changes value from 2147483647 to 2147483648 [-Wimplicit-int-float-conversion]
         (scale * std::numeric_limits<T>::max()) > -1.0f))
                ~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 warnings generated.
/opencv/3rdparty/openjpeg/openjp2/j2k.c:7799:29: warning: implicit conversion from 'int' to 'float' changes value from 21
47483647 to 2147483648 [-Wimplicit-int-float-conversion]
            if (temp_size > INT_MAX) {
                          ~ ^~~~~~~
/usr/lib/llvm-10/lib/clang/10.0.0/include/limits.h:46:19: note: expanded from macro 'INT_MAX'
#define INT_MAX   __INT_MAX__
                  ^~~~~~~~~~~
<built-in>:37:21: note: expanded from here
#define __INT_MAX__ 2147483647
                    ^~~~~~~~~~
1 warning generated.
/opencv/3rdparty/openjpeg/openjp2/tcd.c:2265:35: warning: implicit conversion from 'int' to 'float' changes value from 21
47483647 to 2147483648 [-Wimplicit-int-float-conversion]
                    if (l_value > INT_MAX) {
                                ~ ^~~~~~~
/usr/lib/llvm-10/lib/clang/10.0.0/include/limits.h:46:19: note: expanded from macro 'INT_MAX'
#define INT_MAX   __INT_MAX__
                  ^~~~~~~~~~~
<built-in>:37:21: note: expanded from here
#define __INT_MAX__ 2147483647
                    ^~~~~~~~~~
1 warning generated.
/opencv/3rdparty/openexr/IlmImf/ImfConvert.cpp:110:31: warning: implicit conversion from 'unsigned int' to 'float' change
s value from 4294967295 to 4294967296 [-Wimplicit-int-float-conversion]
    if (isInfinity (f) || f > UINT_MAX)
                            ~ ^~~~~~~~
/usr/lib/llvm-10/lib/clang/10.0.0/include/limits.h:56:37: note: expanded from macro 'UINT_MAX'
#define UINT_MAX  (__INT_MAX__  *2U +1U)
                   ~~~~~~~~~~~~~~~~~^~~
1 warning generated.

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • I agree to contribute to the project under Apache 2 License.
  • To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
  • The PR is proposed to the proper branch
  • There is a reference to the original bug report and related work
  • There is accuracy test, performance test and test data in opencv_extra repository, if applicable
    Patch to opencv_extra has the same branch name.
  • The feature is well documented and sample code can be built with the project CMake

Copy link
Copy Markdown
Contributor

@asmorkalov asmorkalov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@opencv-pushbot opencv-pushbot merged commit 681ee0e into opencv:4.x Dec 8, 2023
@tomoaki0705 tomoaki0705 deleted the warning_fix_clang branch December 8, 2023 11:59
@asmorkalov asmorkalov mentioned this pull request Jan 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants