[Issue 868] New: call to wrong opEquals when trying `new Myclass==new Myclass`

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Jan 21 06:04:03 PST 2007


http://d.puremagic.com/issues/show_bug.cgi?id=868

           Summary: call to wrong opEquals when trying `new Myclass==new
                    Myclass`
           Product: DGCC aka GDC
           Version: 0.21
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: glue layer
        AssignedTo: dvdfrdmn at users.sf.net
        ReportedBy: maniel.rulez at gmail.com


% gdc test.d rational.d -o test
% ./test
auto a = new Rational(1,2);
auto b = new Rational(1,3);
a>b: true
a<b: false
int opEquals_r(Object o): a==b: false
int opEquals(real x): 0.5==a: true
int opEquals(real x): a==0.5: true
int opEquals_r(Object o): a == null: false
int opEquals_r(Object o): null == a: false
% dmd test.d rational.d
gcc test.o rational.o -o test -m32 -lphobos -lpthread -lm
% ./test
auto a = new Rational(1,2);
auto b = new Rational(1,3);
a>b: true
a<b: false
int opEquals(Object o): a==b: 0
int opEquals(real x): 0.5==a: 1
int opEquals(real x): a==0.5: 1
int opEquals(Object o): a == null: 0
int opEquals(Object o): null == a: 0

(this is an output of my testcase)

I'm implementing rational fractions class in D and i found this bug(?). When i 
remove `int opEquals_r(Object o)` method the gdc compiled version tries to use
int opEquals(real x) when i'm trying a==b (both Rational type), and this
generates a segfault while dmd compiled version works ok:>


-- 



More information about the D.gnu mailing list