Skip to content

Compilation warnings in opencv4/opencv2/core/types.hpp #16336

Closed

Description

@bduclaux
System information (version)
  • OpenCV = 4.2.0 compiled from source, and installed in /usr/local/
  • Operating System / Platform = Linux - debian Buster
  • Compiler = g++ 8.3.0
Detailed description

A compile warning error pop-ups in the core/types.hpp file
when using -Wdouble-promotion gcc compilation flag.

usr/local/include/opencv4/opencv2/core/types.hpp:1419:88:   required from here
/usr/local/include/opencv4/opencv2/core/types.hpp:1218:21: warning: implicit conversion from 'float' to 'double' to match other operand of binary expression [-Wdouble-promotion]
     return (double)x*pt.x + (double)y*pt.y;
            ~~~~~~~~~^~~~~
/usr/local/include/opencv4/opencv2/core/types.hpp:1218:38: warning: implicit conversion from 'float' to 'double' to match other operand of binary expression [-Wdouble-promotion]
     return (double)x*pt.x + (double)y*pt.y;
How to reproduce

Just compile the following file:

#include <opencv2/core/types.hpp>
int main(void)
{
	return 0;
}

with : g++ -Wall -Wdouble-promotion -o test test.cc -I/usr/local/include/opencv4/

How to fix

The problem is in the ddot template inside core/types.hpp line 1216.
Code should be changed to:

template<typename _Tp> inline
double Point_<_Tp>::ddot(const Point_& pt) const
{
    return (double)x*(double)(pt.x) + (double)y*(double)(pt.y);
}

Activity

  1. added
    Hackathon
    on Jan 31, 2020
  2. gapry commented on Jan 31, 2020

    @gapry
    Contributor

    Dear @bduclaux

    I've made a PR #16474 to fix the issue. Please review it.

    Thanks.

  3. bduclaux commented on Jan 31, 2020

    @bduclaux
    Author

    @gapry Looks great!
    Thanks !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Hackathonaffected: 3.4category: build/install

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions