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


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|ice-on-invalid-code         |ice-on-valid-code
            Summary|ICE(cgcod.c 1511) returning |ICE(cgcod.c 1511-D1) or bad
                   |string from void main, D1   |code-D2 returning string
                   |only                        |from void main
           Severity|regression                  |critical


--- Comment #3 from Don <clugd...@yahoo.com.au> 2009-09-15 11:31:30 PDT ---
In D2, rather than an ICE, it generates wrong code. Can't really claim
ICE<->wrong-code is a regression.

Technically, this is valid, but I'm actually not sure if this type of code
should be allowed. Should it check for side-effects? IE, void main() { return
2; } --> should this generate a "expression (2) has no effect" error? Seems
like a newbie trap.

Here's a more formal patch against DMD2.032:

Index: statement.c
===================================================================
--- statement.c    (revision 54)
+++ statement.c    (revision 55)
@@ -3454,7 +3454,7 @@
     return gs;
     }

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

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

Reply via email to