codymanix said:
void Foo(int a, int b)
{
a/=b--;
Foo(a, b);
}
Would you consider this as reasonable and correct code that should not
produce a warning?
I don't think it should produce a warning, really. I wouldn't say it's
particularly reasonable code, but I think it's sufficiently difficult
for the compiler to distinguish this from other, more reasonable code
that describing the rules could become more hassle than it's worth.
Note how the recursion is stopped by a DevisionByZeroException.
That's not all you described, however. You talked about conditional
statements. Consider the classic example of recursion:
int Fibonacci (int number)
{
if (number < 2)
{
return 1;
}
return Fibonacci (number-1) + Fibonacci (number-2);
}
Ignore the fact that this particular instance (and many other users of
recursion) can be avoided using iteration - it's an example of the kind
of thing recursion is often used for. According to you, that should
produce a warning. I disagree.
You can always use a #pragma warn to shut the compiler up in such
situatations. to stupid that c# doesn't yet support this nice feature.
No, I don't want to tell the compiler to stop emitting that warning
entirely though - I just want to *always* be able to describe
reasonable code in a way that doesn't cause the compiler to warn me in
the first place.