Thread overview | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
September 07, 2004 Trace/breakpoint trap | ||||
---|---|---|---|---|
| ||||
Hi, There seems to be a problem involving a template class that inherits an interface, and an associative array holding interface references to objects of this class. The following code stops execution when an element is added to the AA (in the Widget class). Before I removed a few printfs, this happened with a segmentation fault, in the version below it happens with a "Trace/breakpoint trap" message. dmd version: 0.101 system: Linux Output: Enter. Constructing SpinBox. Constructing Slot. Widget.register(genericSlot) entered. Trace/breakpoint trap Code: #interface SlotManager #{ # void register(GenericSlot); #} # #interface GenericSlot #{ # void disconnect(); #} # #class Slot() : GenericSlot #{ # this(SlotManager owner, void delegate() callBack) # { # printf("Constructing Slot.\n"); # owner.register(this); # } # # void disconnect() {} #} # #class Widget : SlotManager #{ # void register(GenericSlot s) # { # printf("Widget.register(genericSlot) entered.\n"); # _slots[s] = s; # printf("Widget.register(genericSlot) completed.\n"); # } # # #private: # GenericSlot[GenericSlot] _slots; #} # #class SpinBox : Widget #{ # void increase() # { # } # # Slot!() up; # # this() # { # printf("Constructing SpinBox.\n"); # up = new Slot!()(this, &increase); # printf("Slot newed.\n"); # } #} # #void main() #{ # printf("Enter.\n"); # SpinBox sb = new SpinBox; # printf("SpinBox created.\n"); # #} Bastiaan. |
September 13, 2004 [Workaround] Trace/breakpoint trap | ||||
---|---|---|---|---|
| ||||
Posted in reply to Bastiaan Veelo | The bug remains, but I can work around it by using MinTL's SortedSet instead of the build-in AA. Instead of # Foo[Foo] foos; use # SortedSet!(Foo) foos; Thanks Ben :-) Bastiaan. |
September 13, 2004 [Smaller example, no workaround] Trace/breakpoint trap | ||||
---|---|---|---|---|
| ||||
Posted in reply to Bastiaan Veelo | This is a smaller example, exposing the same bug (I think). This time, using MinTL does not help :-( #import mintl.util; # #/* Segmentation fault when Base is an interface. Okay when Base is a #class. */ #interface Base #//class Base #{ # int id(); #// int id() { return 0; } #} # #class Foo : Base #{ # int id() { return 123; } #} # #class Bar : Base #{ # int id() { return 987; } #} # #int main() #{ # Base foo = new Foo; // foo declared as Base or Foo does not # Base bar = new Bar; // matter, problem presists. # #// SortedSet!(Base) set; # Base[Base] set; # # set[foo] = foo; # set[bar] = bar; # #// printf("Length set = %d.\n", set.length()); # printf("Length set = %d.\n", set.length); # # foreach( Base b; set ) printf("id: = %d.\n", b.id() ); # return 0; #} |
Copyright © 1999-2021 by the D Language Foundation