www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 3432] New: ICE(e2ir.c): declaring local template function and casting it

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

           Summary: ICE(e2ir.c): declaring local template function and
                    casting it
           Product: D
           Version: 2.036
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Keywords: ice-on-invalid-code
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: clugdbug yahoo.com.au


--- Comment #0 from Don <clugdbug yahoo.com.au> 2009-10-21 07:13:49 PDT ---
void main() {
    void fun(T)() {}
    int x = cast(int)fun;
}
----

fun(T)
Internal error: e2ir.c 644

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


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|ice-on-invalid-code         |ice-on-valid-code
            Summary|ICE(e2ir.c): declaring      |ICE(e2ir.c): casting local
                   |local template function and |template function
                   |casting it                  |


--- Comment #1 from Don <clugdbug yahoo.com.au> 2009-10-21 07:16:59 PDT ---
Oops, local template functions seem to be legal in D2. I didn't realize that.
So this is valid code.

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


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch
            Version|2.036                       |1.00
            Summary|ICE(e2ir.c): casting local  |ICE(e2ir.c): casting
                   |template function           |template expression


--- Comment #2 from Don <clugdbug yahoo.com.au> 2009-10-22 01:35:53 PDT ---
Applies to D1 as well. Doesn't require nested templates. Test case (ICEs even
on DMD0.175):
---
void fun(T=int)(int w, int z) {}

void main() {
    auto x = cast(void function(int, int))fun;
}
---
Root cause: Shouldn't be able to cast from void to anything else (except void).

This patch also moves some error messages from e2ir into the front-end where
they belong.

-----
PATCH: expression.c, line 7423 (DMD 2.035, svn rev215):

    if (!to->equals(e1->type))
    {
        e = op_overload(sc);
        if (e)
        {
        return e->implicitCastTo(sc, to);
        }
+        /* Cannot cast from void to anything other than void
+         */
+        if (e1->type == Type::tvoid) {
+        error("'%s' is void and cannot be cast to %s", e1->toChars(),
to->toChars());
+        return new ErrorExp();
+        }
    }

    Type *t1b = e1->type->toBasetype();
    Type *tob = to->toBasetype();

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


Leandro Lucarella <llucax gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |llucax gmail.com


--- Comment #3 from Leandro Lucarella <llucax gmail.com> 2009-10-31 22:47:13
PDT ---
SVN commit: http://www.dsource.org/projects/dmd/changeset/232

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


Walter Bright <bugzilla digitalmars.com> changed:

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


--- Comment #4 from Walter Bright <bugzilla digitalmars.com> 2009-11-06
11:32:07 PST ---
Fixed dmd 1.051 and 2.036

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