strange _sort_ of bug

David Medlock noone at nowhere.com
Mon Sep 25 10:07:36 PDT 2006


Walter Bright wrote:
> David Medlock wrote:
> 
>> I am getting an Access Violation using the array built-in sort.
>>
>> My structure looks quite harmless:
>>
>> class   EdgeInfo
>> {
>>   int     from, to;
>>   float   cost = 0;
>>
>>   public int     opCmp( Object o )
>>   {
>>     EdgeInfo e = cast(EdgeInfo)o;
>>     float other = e.cost;
>>     if ( cost < other ) return -1;
>>     if ( equal( other , cost ) ) return 0; else return 1;
>>   }
>> }
> 
> 
> Try checking that o is not null.
Well originally the EdgeInfo was an array of structs, each of which is 
appended on the array(so no nulls possible).  I tried EdgeInfo* and 
EdgeInfo, got the error either way.

Ended up taking the long way around the issue: I ported a public domain 
heapsort and insertion sort to D.

I can post these if anyone wants em.

-DavidM



More information about the Digitalmars-d-bugs mailing list