Thread overview
[Issue 1692] New: Abstract class dynamic creation bug
Nov 24, 2007
d-bugmail
Nov 25, 2008
d-bugmail
Apr 23, 2009
d-bugmail
Jul 01, 2011
yebblies
Sep 14, 2011
yebblies
Oct 14, 2011
Walter Bright
November 24, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1692

           Summary: Abstract class dynamic creation bug
           Product: D
           Version: 1.023
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla@digitalmars.com
        ReportedBy: jaroslav.kroft@seznam.cz


Hi, here is some piece of code which most probably doesn't work one expect to.

version (Tango) {
  import tango.io.Console;
  pragma(lib, "tango-user-dmd");
} else {
  import std.stdio;
}

class AbstractError: Error {
  this (char[] msg = null) {
    super(msg);
  }
}

abstract class Dummy {
  public {
    this() {
      if (!this) {
        throw new AbstractError();
      }
    }
  }

  char[] Value();
}

int main(char[][] args)
{
  ClassInfo ci = ClassInfo.find("hello.Dummy");
  if (ci) {
    Object o = ci.create();
    if (o) {
version (Tango) {
      Cout(o.toUtf8);
} else {
  writef(o.toString);
}
    }
  }
  return 0;
}

This code would compile without any error, but when you try to run, you will receive AV most probably directly in the constructor. I guess that in this case the call of ClassInfo.create should either return null or throw some kind of error....


-- 

November 25, 2008
http://d.puremagic.com/issues/show_bug.cgi?id=1692


samukha@voliacable.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |samukha@voliacable.com




------- Comment #1 from samukha@voliacable.com  2008-11-25 08:06 -------
*** Bug 2453 has been marked as a duplicate of this bug. ***


-- 

April 23, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=1692





------- Comment #2 from gide@nwawudu.com  2009-04-23 05:01 -------
Added example from Bug 2453.

abstract class C {
}

void main()
{
    auto c = cast(C)C.classinfo.create();
    assert(c is null); // should pass or classinfo.create should throw an
exception
}


-- 

July 01, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=1692


yebblies <yebblies@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch
                 CC|                            |yebblies@gmail.com
          Component|DMD                         |druntime
           Platform|x86                         |All
         OS/Version|Windows                     |All


--- Comment #3 from yebblies <yebblies@gmail.com> 2011-07-01 19:57:29 EST ---
The bug is primarily in druntime, but requires a dmd change to pass more information along.

https://github.com/D-Programming-Language/dmd/pull/186 https://github.com/D-Programming-Language/druntime/pull/34

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
September 14, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=1692


yebblies <yebblies@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |opantm+spam@gmail.com


--- Comment #4 from yebblies <yebblies@gmail.com> 2011-09-14 22:36:40 EST ---
*** Issue 6667 has been marked as a duplicate of this issue. ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 14, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=1692


Walter Bright <bugzilla@digitalmars.com> changed:

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


--- Comment #5 from Walter Bright <bugzilla@digitalmars.com> 2011-10-13 23:25:02 PDT ---
https://github.com/D-Programming-Language/druntime/commit/b7270004a95c33372e5b15bc72069c001b064acf

https://github.com/D-Programming-Language/phobos/commit/23109c032d9f3117f154a8bb0f588ef9ada85565

https://github.com/D-Programming-Language/dmd/commit/0a9a27646954d73dd32e38175a6126fbba6bd334

https://github.com/D-Programming-Language/dmd/commit/90dfda907b4b634effc12bc7ea546ab6b3ffe1b0

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