% 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:>
Comment #1 by maniel.rulez — 2007-01-21T08:05:49Z
Created attachment 94
a testcase for this bug
Comment #2 by maniel.rulez — 2007-01-21T08:06:42Z
Created attachment 95
rational class implementation
Comment #3 by dvdfrdmn — 2007-01-27T16:05:41Z
I cannot reproduce the problem.
Did you build from source or use the binaries? If the former, please try the binary package. If you still have the problem, please post the exact source and command line that generates the crash. Also, please post a backtrace.
Thanks!
Comment #4 by maniel.rulez — 2007-01-28T14:25:54Z
Ech, i'm sorry, just noticed it was my fault, there was some rational.{d.23.greg,di,o} files laying in my home directory [wtf is this raional.d.23.greg file?:P] where i was compilong this test program...:) After i deleted them i've noticed that good opEquals methods are called and everythiong is ok:) Sorry for a problem:P Issue marked as WORKSFORME:)