Why am I getting warning C4756: Constant arithmetic overflow when returning float :: PositiveInfinity?

I have a code that returns float :: PositiveInfinity to indicate that the event will never happen, but for some reason the compiler (MS Visual Studio 2013) gives me the following warning:

warning C4756: overflow in constant arithmetic
      

This code looks like this:

property float MinsRemainingUntilNextEvent
{
    virtual float get()
    { 
        return float::PositiveInfinity;
    }
}
      

What does this mean and I don't care? MS documentation didn't explain it to me ...

+3


source to share


1 answer


I would promise that the compiler designers chose a warning for any floating point expression that could be evaluated at compile time, and the result of which was +inf

, which means that a warning will be systematically emitted for float::PositiveInfinity

.



Your use float::PositiveInfinity

is completely legal and safe. Ignore the warning. I would like to recommend you get a better compiler, but GCC is just as silly when it comes to floating point.

+5


source







All Articles