www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 15274] New: typeid(this) inside of an interface contract

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

          Issue ID: 15274
           Summary: typeid(this) inside of an interface contract segfaults
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: initrd.gz gmail.com

Example code:

    interface MyFace {
        Object bar()
        out(v) {
            assert(typeid(this));
        }
    }

    class MyClass : MyFace {
        override Object bar() {
            return new MyClass();
        }
    }

    void main() {
        (new MyClass()).bar();
    }

This code causes a segfault when ran. Removing the `assert(typeid(this))` line
causes the error to go away. Putting the out contract on the class also does
not cause an error.

GDB output:

(gdb) bt


    v= 0x7fffffffdca0: 0x7ffff7ed0020) at ./test.d:5

    at ./test.d:10








Version:

 dmd --version
DMD64 D Compiler v2.068.2 Copyright (c) 1999-2015 by Digital Mars written by Walter Bright --
Nov 02 2015