www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 3344] New: Internal error: e2ir.c 644 by a strange return statement

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3344

           Summary: Internal error: e2ir.c 644 by a strange return
                    statement
           Product: D
           Version: 2.032
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: rayerd.wiz gmail.com



PDT ---
type main.d
void f(T)(){} void main() { return f; }
dmd main
f(T) Internal error: e2ir.c 644 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 25 2009
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3344


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ice-on-valid-code
                 CC|                            |clugdbug yahoo.com.au
            Version|2.032                       |1.00
            Summary|Internal error: e2ir.c 644  |ICE(e2ir.c) returning a
                   |by a strange return         |void function from main()
                   |statement                   |



Not a D2 bug. Fails even in DMD 0.165.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 25 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3344


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|ice-on-valid-code           |ice-on-invalid-code, patch
            Summary|ICE(e2ir.c) returning a     |ICE(e2ir.c) returning an
                   |void function from main()   |invalid function from
                   |                            |main()



This is clearly invalid code.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 29 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3344




This is happening because when return exp; is changed into exp; return;, the 
semantic pass never gets run on the expression.

-------
PATCH: iin statement.c, around line 3464, in Statement 
*ReturnStatement::semantic(Scope *sc)

=====
    /* Replace:
     *    return exp;
     * with:
     *    exp; return;
     */
    Statement *s = new ExpStatement(loc, exp);
+    s->semantic(sc); 
==========

CAUTION:
This patch also disallows code like " void foo() { return 7; }"
This shows up several bugs in Phobos and in the DMD test suite.
If there's a reason why such bug-prone code should continue to be accepted, a 
more complicated patch will be required.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 29 2009
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3344


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla digitalmars.com
         Resolution|                            |FIXED



13:48:24 PDT ---
Fixed dmd 1.049 and 2.034

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