[Bug 5] false warning: no return at end of function

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Mar 18 17:20:09 PST 2006


http://d.puremagic.com/bugzilla/show_bug.cgi?id=5


unknown at simplemachines.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |unknown at simplemachines.org
            Version|0.147                       |0.149




------- Comment #2 from unknown at simplemachines.org  2006-03-18 19:20 -------
The code for loops is always returning true for cases like this:

int foo()
{
    int[] a;

    foreach (int v; a)
    {
        return 1;
    }
}

Which, in this case, is an error (a is empty.)  As I recall, this is similar to
examples Walter gave of why he dislikes warnings.  It's still calling it's
insides' fallOffEnd() for "statement is not reachable" warnings.

It appears the intention of the code in CompoundStatement's fallOffEnd() seems
to be not to show a zillion "statement is not reachable" messages.  But, it is
the cause of why this says "no return at end of function":

int foo()
{
        bar();
        assert(false);
        bar();
}

It seems to me that TryFinallyStatement should indeed be changed as you
suggest.

I'm going to attach a patch because I think they are much more expressive for
communication between programmers than words are.

Thanks,
-[Unknown]


-- 




More information about the Digitalmars-d-bugs mailing list