www.digitalmars.com         C & C++   DMDScript  

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

reply d-bugmail puremagic.com writes:
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 users.sf.net
        ReportedBy: maniel.rulez 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:>


-- 
Jan 21 2007
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=868





------- Comment #1 from maniel.rulez gmail.com  2007-01-21 08:05 -------
Created an attachment (id=94)
 --> (http://d.puremagic.com/issues/attachment.cgi?id=94&action=view)
a testcase for this bug


-- 
Jan 21 2007
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=868





------- Comment #2 from maniel.rulez gmail.com  2007-01-21 08:06 -------
Created an attachment (id=95)
 --> (http://d.puremagic.com/issues/attachment.cgi?id=95&action=view)
rational class implementation


-- 
Jan 21 2007
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=868


dvdfrdmn users.sf.net changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED




------- Comment #3 from dvdfrdmn users.sf.net  2007-01-27 16:05 -------
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!


-- 
Jan 27 2007
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=868


maniel.rulez gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |WORKSFORME




------- Comment #4 from maniel.rulez gmail.com  2007-01-28 14:25 -------
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:)


-- 
Jan 28 2007