I have the following C# code, I'm using VS 2012 and all my warnings are treated as errors (although this probably doesn't have much relevance).
private static readonly int MAX_RADIUS_KM = 16;
private void Test() {
int i = 2 * MAX_RADIUS_KM;
int i2 = 2;
}
"The variable [x] is assigned, but its value is never used" is shown for i2
, but not for i
. Why? Is this a bug or something's happening behind the scenes? I'd be surprised by the latter, but if so, what's happening that makes i
to avoid that warning?
The following also exhibits failure to emit warning for unused i
:
private void Test(int foo) {
int i = 2 * foo;
int i2 = 2;
}
And another (i2
in this case):
private void Test()
{
int i = 2 * 3;
int i2 = i;
}