Bug 868 – call to wrong opEquals when trying `new Myclass==new Myclass`

Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Linux
Creation time
2007-01-21T08:03:00Z
Last change time
2015-06-09T05:15:08Z
Assigned to
dvdfrdmn
Creator
maniel.rulez

Attachments

IDFilenameSummaryContent-TypeSize
94test.da testcase for this bugtext/plain420
95rational.drational class implementationtext/plain4625

Comments

Comment #0 by maniel.rulez — 2007-01-21T08:03:56Z
% 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:)