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





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





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





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





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