Bug 15274 – typeid(this) inside of an interface contract segfaults
Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2015-11-02T16:14:00Z
Last change time
2015-11-03T12:44:31Z
Assigned to
nobody
Creator
initrd.gz
Comments
Comment #0 by initrd.gz — 2015-11-02T16:14:37Z
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
Comment #1 by k.hara.pg — 2015-11-03T12:44:31Z
*** This issue has been marked as a duplicate of issue 7517 ***