
On Thu, Nov 12, 2009 at 11:07 AM, Stewart, Robert <Robert.Stewart@sig.com> wrote:
Emil Dotchevski wrote:
On Thu, Nov 12, 2009 at 9:58 AM, Stewart, Robert <Robert.Stewart@sig.com> wrote:
Emil Dotchevski wrote:
If the purpose of the test is to show that variant triggers the same warning as would an ordinary int-to-short assignment, getting the warning here is a good thing.
If the purpose of the test is to prove that assigning to variant has the same runtime behavior as non-variant code, as I suggested above, the warning is unwarranted noise.
Lets assume it's the latter. Still, I don't think it is fair to label the warning as unwarranted noise. It would be noise if there were 200 warnings reported from this test. Somewhere between 1 and 200, warnings can be classified as additional information, not noise.
If a warning tells you that the code is incorrect (as in, you should have used short instead of int for the type of a given variable) then sure, it should be fixed. If it tells you that your correct code might be wrong, then seeing the warning is a good thing -- unless it becomes annoying at which point it is silenced for the sake of sanity.
In that case, the warning is noise. The test is using a small integer value that can be verified to fit in a short on any supported platform (is there a platform that wouldn't hold 58 in a short?). Having determined that 58 is a safe value for the int-to-short assignment test, one should silence the warning.
By default, in C and C++ we should assume that assigning int to short is safe because too many expressions that are assigned to shorts are of type int. Without this assumption, we can't even be sure that incrementing a short is safe because that too does an implicit conversion from int. So, in my personal opinion this particular warning should be disabled to begin with. But another reasonable assumption is that if a warning is enabled, it has value to someone. The presence of this warning in this particular test indicates to anyone who cares to look at the log that for those who find value in this warning, the warning is not (inappropriately?) silenced (within the library.) Emil Dotchevski Reverge Studios, Inc. http://www.revergestudios.com/reblog/index.php?n=ReCode