Thread overview
[Bug 5] false warning: no return at end of function
Mar 05, 2006
d-bugmail
Mar 19, 2006
d-bugmail
Mar 19, 2006
d-bugmail
Mar 19, 2006
d-bugmail
March 05, 2006
http://d.puremagic.com/bugzilla/show_bug.cgi?id=5


braddr@puremagic.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|braddr@puremagic.com        |walter@digitalmars.com




-- 

March 19, 2006
http://d.puremagic.com/bugzilla/show_bug.cgi?id=5


unknown@simplemachines.org changed:

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




------- Comment #2 from unknown@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]


-- 

March 19, 2006
http://d.puremagic.com/bugzilla/show_bug.cgi?id=5





------- Comment #3 from unknown@simplemachines.org  2006-03-18 19:27 -------
Created an attachment (id=5)
 --> (http://d.puremagic.com/bugzilla/attachment.cgi?id=5&action=view)
Change CompoundStatement and TryFinallyStatement.

This patch:

1. Changes the behavior of CompoundStatement so that, if there is ever a child statement which does fall off, it does not issue a "no return" warning.

2. Keeps the existing functionality of showing a "statement not reachable" warning only once per early return.

3. Changes TryFinallyStatement so that the finally may fall off so long as the try does not.

-[Unknown]


-- 

March 19, 2006
http://d.puremagic.com/bugzilla/show_bug.cgi?id=5


bugzilla@digitalmars.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED




------- Comment #4 from bugzilla@digitalmars.com  2006-03-19 02:05 -------
Fixed 0.150.


--