Is there a gcc flag so that long to short conversions generate a warning about possible data loss?
I am working on a C ++ application that compiled for both Visual Studio (2005) and GCC 4.2 (for Mac OS X).
The warnings that Visual Studio emits follow this pattern:
: warning C4244: 'argument' : conversion from 'long' to 'short', possible loss of data
I tried Conversion, but that is not quite what I am looking for. The only thing I managed to find was an experimental flag - Wcoercion, associated with GCC 4.3 (which I'm not sure if we want to invest in it yet).
April 22, 2009 @ 11:00 AM EST Edit: To clarify, I want to see this warning. We have code where we want to know when data loss will occur. If I have a code:
unsigned long value1 = LONG_MAX;
std::cout << "value1: " << value1 << std::endl;
unsigned short value2 = value1;
std::cout << "value2: " << value2 << std::endl;
:
value1: 2147483647
2: 65535
, , . Visual Studio.
gcc 4.2?