Re: compiler warnings for unconditional recursive calls
- From: "Tim Rowe" <news@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Sat, 9 Jun 2007 16:01:06 +0100
"cody" <deutronium@xxxxxx> wrote in message
news:%231RAZaVqHHA.4536@xxxxxxxxxxxxxxxxxxxxxxx
Why doesn't the compiler give me any warning if it encounters code like
the following:
void foo()
{
// some code here
// foo() ist not nested in a pre-condition loop, some if- or else-
// block and no return statement appears before it.
foo();
}
The compiler should recognize something like that, shouldn't it?
Why? The general case of determining whether code terminates is inhaously
hard (the "halting problem"), and the few specific cases a compiler might be
able to detect are such a timy minority it doesn't seem worth it. If you
really do need to be sure that a method terminates consider implementing a
loop variant of some sort (they're already in Spec#:
http://channel9.msdn.com/wiki/default.aspx/SpecSharp.LoopVariants). If you
really /really/ need to be sure that a method terminates, you probably
shouldn't be using C# but rather something formal like SPARK.
(http://www.praxis-his.com/sparkada/).
.
- References:
- Prev by Date: Re: Looking for Tips/Writeup on overall approach to Exception Processing
- Next by Date: Re: Getting the default printer in 64-bit Vista
- Previous by thread: Re: compiler warnings for unconditional recursive calls
- Next by thread: interfaces
- Index(es):
Relevant Pages
|