Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.
7956 Discussions

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

afbase
Beginner
2,516 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
Honored Contributor III
2,516 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).
0 Kudos
Judith_W_Intel
Employee
2,516 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.
0 Kudos
Reply