D - dynamic_cast only?
Steve Teale
steve.teale at britseyeview.com
Sun Dec 25 05:39:15 PST 2011
On Sun, 25 Dec 2011 08:37:21 +0000, Steve Teale wrote:
So what do you think is happening here?
ColorSelectionDialog csd = new ColorSelectionDialog("Choose a
Color");
writefln("csd %s", csd);
void* vp = cast(void*) csd.getColorSelection();
ColorSelection cs = cast(ColorSelection) vp;
writefln("cs %s", cs);
cs.setCurrentColor(cto.baseColor);
writeln("A");
Output:
csd gtk.ColorSelectionDialog.ColorSelectionDialog
cs gtk.Widget.Widget
Segmentation fault
The segfault is presumably because Widget does not have a setCurrentColor
method, but why is the cast being ignored? Is the compiler optimizing the
intermediate cast to void away? I don't find the asm from obj2asm helpful.
Steve
More information about the Digitalmars-d
mailing list