Back to Recurring programming techniques in Pastel
When a compiler emits a warning, it might or might not mean that changes are warranted in the code itself. While most of the warnings are appropriate, some are not, and further, to some warnings there are no practical solutions. In these cases, instead of modifying your code, disabling the warnings is the right thing to do. Here we list all the warnings we have disabled in Pastel, and explain why we have done that.
4351 new behavior: elements of array 'array' will be default initialized
This warning notifies of changed behaviour compared to a previous version of Visual Studio. Because the new behaviour is the correct one as defined by the C++ standard, the warning carries no information.
4996 'function': was declared deprecated
This warning is seen on common C++ Standard Library functions, and is an incorrect one. This warning appeared alongside with the Microsoft's 'safe' implementation of the STL in Visual Studio 2008. Considering that the reported C++ Standard Library functions are not deprecated in the C++ Standard, and will not be deprecated in the next C++ standard either, the only motivation seems to be to promote the safe implementation.
4018 'expression' : signed/unsigned mismatch
This warning notifies that a signed-unsigned integer conversion is taking place. This conversion is generally an information-destroying process in both directions. Generally, you should avoid this situation by not using unsigned integers. However, if this not possible, there is nothing you can do. While a cast might get rid of the warning, it does not get rid of the problem. A better approach is to disable the warning: if at some later time an unsigned-signed conversion is thought to cause problems, then, by enabling the warning, the compiler can help you to locate those places again.
4244 'argument' : conversion from 'type1' to 'type2', possible loss of data.
This warning refers to a floating point type being converted to an integer type. It is self-evident that there is possible loss of data when doing the conversion, and this is most of the time also the intention (rounding). This warning essentially urges to use a cast to make the conversion explicit to the reader. From the compilers view, this cast is redundant, since the implicit conversion will take effect in any case, and can be seen as a case-by-case supression of the warning. We find the redundant casts making the code less clear, and thus disable the warning instead. At a later time, if desired, the compiler can help to locate these places by enabling the warning.
4305 'identifier' : truncation from 'type1' to 'type2'
4251 'identifier' : class 'type' needs to have dll-interface to be used by clients of class 'type2'
4267 'var' : conversion from 'size_t' to 'type', possible loss of data
4312 'operation' : conversion from 'type1' to 'type2' of greater size
4224 nonstandard extension used : formal parameter 'identifier' was previously defined as a type
4180 qualifier applied to function type has no meaning; ignored
4800 'type' : forcing value to bool 'true' or 'false' (performance warning)
4804 'operation' : unsafe use of type 'bool' in operation