www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 15639] New: std.experimental.allocator enables abstract class

https://issues.dlang.org/show_bug.cgi?id=15639

          Issue ID: 15639
           Summary: std.experimental.allocator enables abstract class
                    instantiation
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: major
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: olivier.pisano laposte.net

With std.experimental.allocator.make, one can instantiate an abstract class.
Calling an abstract method segfaults.

Tested with both 2.069.2 and 2.070.

import std.experimental.allocator;
import std.stdio;

abstract class Toto
{
    void f()
    {
        writeln("f() called");
    }

    abstract void g();
}

void main()
{
    auto toto = theAllocator.make!Toto(); 
    toto.f();                             // prints "f() called"
    toto.g();                             // segfaults
}

--
Feb 02 2016