Skip to content

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

@bduclaux

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);
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions