I have a problem that I'm sure is easy to fix, but I'm at a loss ...
I have a template that executes the following code:
T value = d;
if ( std::numeric_limits< T >::is_signed )
{
if ( value < 0 )
{
*this += _T( "-" );
value = -(signed)value;
}
}
Now, for obvious reasons, GCC gives me a warning (the comparison is always incorrect due to the limited range of data types) when this code is compiled for an unsigned type. I fully understand the arguments behind this, and I introduced a numeric_limits check to find out if I can make the compiler shut up (it worked for MSVC). Alas, in GCC I get a warning. Is there a way (if I don't turn off the warning, which I donβt even know if you can do with GCC) to fix this warning? The code will never be called in any case, and I would suggest that the optimizer will compile it, but I can not get rid of the warning.
Can someone give me a solution?
Hooray!
source
share