Quantcast
Channel: Intel® C++-Compiler
Viewing all articles
Browse latest Browse all 1665

Warn on implicit conversion that may change sign of integer value

$
0
0

Hello,

when compiling the following code

unsigned int bad_sign_conv(int i)
{
   unsigned int u = i;
   return u;
}

with Intel(R) C++ Compiler XE for applications running on IA-32, Version 13.1.3.192 Build 20130607 like so

$ icpc -c -Wconversion -Wsign-conversion demo.cc

no diagnostics are emitted.

When compiling with e.g. g++ (Debian 4.4.5-8) 4.4.5 with the same switches, like so

$ g++ -c -Wconversion -Wsign-conversion demo.cc

demo.cc: In function ‘unsigned int bad_sign_conv(int)’:

demo.cc:3: warning: conversion to ‘unsigned int’ from ‘int’ may change the sign of the result

above warning is emitted as expected.  How do I get Intel C++ to warn me likewise?

PS There is also a "Diagnostic 68: integer conversion resulted in a change of sign", but that seems to trigger only when the sign is definitely changed?  (https://software.intel.com/en-us/articles/cdiag68)


Viewing all articles
Browse latest Browse all 1665

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>