www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.dtl - MinTL segfault.

reply Bastiaan Veelo <Bastiaan.N.Veelo ntnu.no> writes:
This is likely a bug in dmd, probably related to 
http://www.digitalmars.com/drn-bin/wwwnews?digitalmars.D.bugs/1810

dmd 0.101 on Linux.


#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()
#{
#	Foo foo = new Foo;	// Declaring foo and bar as Base
#	Bar bar = new Bar;	// does not help.
#
#	SortedSet!(Base) set;
#	
#	set[foo] = foo;
#	set[bar] = bar;
#
#	printf("Length set = %d.\n", set.length());
#	
#	foreach( Base b; set ) printf("id: = %d.\n", b.id() );
#	return 0;
#}
Sep 13 2004
parent "Ben Hinkle" <bhinkle mathworks.com> writes:
Bummer. It looks like TypeInfo compare functions are busted for interfaces.
If you try to run
 TypeInfo ti = typeid(foo);
 ti.compare(&foo,&bar);
you'll error out. On win32 I get a Win32 Exception. Probably since the
declaration of compare is with void* instead of a specific type it gets all
confused about calling opCmp. Nasty. I'm cross-posting to bugs.

"Bastiaan Veelo" <Bastiaan.N.Veelo ntnu.no> wrote in message
news:ci495h$1alr$1 digitaldaemon.com...
 This is likely a bug in dmd, probably related to
 http://www.digitalmars.com/drn-bin/wwwnews?digitalmars.D.bugs/1810

 dmd 0.101 on Linux.


 #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()
 #{
 # Foo foo = new Foo; // Declaring foo and bar as Base
 # Bar bar = new Bar; // does not help.
 #
 # SortedSet!(Base) set;
 #
 # set[foo] = foo;
 # set[bar] = bar;
 #
 # printf("Length set = %d.\n", set.length());
 #
 # foreach( Base b; set ) printf("id: = %d.\n", b.id() );
 # return 0;
 #}
Sep 13 2004