www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2399] New: ICE on casting function to delegate

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

           Summary: ICE on casting function to delegate
           Product: D
           Version: 2.019
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: terranium yandex.ru


alias void delegate() dg;
void fun(){}
void gun()
{
  dg d=cast(dg)&fun;
}


-- 
Oct 08 2008
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2399


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code
                 CC|                            |clugdbug yahoo.com.au
            Version|2.019                       |1.044




--- Comment #1 from Don <clugdbug yahoo.com.au>  2009-05-14 02:45:00 PDT ---
If compiled with -O, this generates wrong code instead. Also applies to D1.

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


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|ICE on casting function to  |ICE(cgcod.c) on casting
                   |delegate                    |function to delegate




--- Comment #2 from Don <clugdbug yahoo.com.au>  2009-05-15 00:30:01 PDT ---
Internal error: ..\backend\cgcod.c 1549

This is almost certainly related to bug 2323, bug 2672, and bug 2875.

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


Don <clugdbug yahoo.com.au> changed:

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




--- Comment #3 from Don <clugdbug yahoo.com.au>  2009-05-15 14:35:46 PDT ---
The root cause is in cast.c, 
Expression *SymOffExp::castTo(Scope *sc, Type *t).
Casting from a function pointer to a delegate must be forbidden.
This patch also fixes Bug 2875.


============
   else if (tb->ty == Tdelegate && f->isNested())
    {
    e = new DelegateExp(loc, new IntegerExp(0), f);
    e = e->semantic(sc);
   } 
+    else if (tb->ty == Tdelegate) {
+    error("Cannot cast from function pointer to delegate");
+        return this;
+   }
    else
    {
    e = new SymOffExp(loc, f, 0);
    e->type = t;
    }

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


Walter Bright <bugzilla digitalmars.com> changed:

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




--- Comment #4 from Walter Bright <bugzilla digitalmars.com>  2009-07-09
02:54:46 PDT ---
Fixed dmd 2.031

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