Intel® C++ Compiler
Support and discussions for creating C++ code that runs on platforms based on Intel® processors.
Announcements
Welcome to the Intel Community. If you get an answer you like, please mark it as an Accepted Solution to help others. Thank you!
For the latest information on Intel’s response to the Log4j/Log4Shell vulnerability, please see Intel-SA-00646
7594 Discussions

Compiling OpenCV: warning #68: integer conversion resulted in a change of sign

afbase
Beginner
801 Views
Hello,

I have an Intel Core Duo (T2350)
CPU. I'm running Ubuntu 9.10 Karmic Koala. I am using icc version 11.1 to compile some OpenCV code I made (using the i386 Ubuntu repository version).

When I compile the code with:

icc `pkg-config --cflags opencv` `pkg-config --libs opencv` edge_v2.cpp -vec-report

I receive errors:
/usr/local/include/opencv/cxmat.hpp(346): warning #68: integer conversion resulted in a change of sign

if( refcount && CV_XADD(refcount, -1) == 1 )
^
/usr/local/include/opencv/cxmat.hpp(3722): warning #68: integer conversion resulted in a change of sign
if( refcount && CV_XADD(refcount, -1) == 1 )
^
/usr/local/include/opencv/cxmat.hpp(4116): warning #68: integer conversion resulted in a change of sign
if( hdr && CV_XADD(&hdr->refcount, -1) == 1 )
^
What does this mean? How do I go about correcting this? Any help would be much appreciated.
0 Kudos
2 Replies
jimdempseyatthecove
Black Belt
801 Views

CV_XADD on x32 is int (__int32), and on x64 is long (__int64). The first arg is an address of volatile version of the int/long and the second arg is of type int/long. Assure that refcount is of proper type as well as the literals. -1 and 1are int not long (if you are compiling for x64).
Judith_W_Intel
Employee
801 Views

CV_XADD on x32 is int (__int32), and on x64 is long (__int64). The first arg is an address of volatile version of the int/long and the second arg is of type int/long. Assure that refcount is of proper type as well as the literals. -1 and 1are int not long (if you are compiling for x64).

The warning is not about integer size but about signedness.

Cause:
Conversion of integer resulted in sign change. Usually this happens when an unsigned integral
type was assigned -1.

Example:

unsigned inti = -1;


Resolution:
Conversion from a signed int to unsigned leads to change of sign. This
might result in an unexpected behavior of the code. If the sign of the
integer is not a concern, then this diagnostic can be ignored.
Otherwise, do not assign a signed value to unsigned type.
Reply