http://d.puremagic.com/issues/show_bug.cgi?id=3160


Don <clugd...@yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch


--- Comment #2 from Don <clugd...@yahoo.com.au> 2009-09-15 08:44:16 PDT ---
ROOT CAUSE: The logic for inserting a "return 0" at the end of a void main, and
the logic for evaluating the return expression in a void function, interact
incorrectly. The case where BOTH these things need to happen was missing. BTW,
this is probably wrong in D2 as well.


PATCH: statement.c, last lines of ReturnStatement::semantic (around line 2891):

-    if (exp && tbret->ty == Tvoid && !fd->isMain())
+    if (exp && tbret->ty == Tvoid && !implicit0)
    {
    /* Replace:
     *    return exp;
     * with:
     *    exp; return;
     */
    Statement *s = new ExpStatement(loc, exp);
    loc = 0;
+    if (fd->isMain()) exp = new IntegerExp(0);
+    else
        exp = NULL;
    return new CompoundStatement(loc, s, this);
    }
    return this;
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

Reply via email to