November 02, 2015 [Issue 15274] New: typeid(this) inside of an interface contract segfaults | ||||
|---|---|---|---|---|
| ||||
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 #0 0x000000000041f3d9 in invariant._d_invariant() () #1 0x000000000041dbd4 in test.MyFace.bar() (this=0x7fffffffdca8, v=@0x7fffffffdca0: 0x7ffff7ed0020) at ./test.d:5 #2 0x000000000041dc45 in test.MyClass.bar() (this=0x7ffff7ed0000) at ./test.d:10 #3 0x000000000041dc80 in D main () at ./test.d:16 #4 0x000000000041f35f in rt.dmain2._d_run_main() () #5 0x000000000041f2ba in rt.dmain2._d_run_main() () #6 0x000000000041f31b in rt.dmain2._d_run_main() () #7 0x000000000041f2ba in rt.dmain2._d_run_main() () #8 0x000000000041f23a in _d_run_main () #9 0x000000000041dd28 in main () Version: > dmd --version DMD64 D Compiler v2.068.2 Copyright (c) 1999-2015 by Digital Mars written by Walter Bright -- | ||||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply