digitalmars.D.bugs - [Issue 1038] New: explicit class cast breakage in 1.007
- d-bugmail puremagic.com (28/28) Mar 08 2007 http://d.puremagic.com/issues/show_bug.cgi?id=1038
- d-bugmail puremagic.com (13/13) Mar 08 2007 http://d.puremagic.com/issues/show_bug.cgi?id=1038
- d-bugmail puremagic.com (6/6) Mar 11 2007 http://d.puremagic.com/issues/show_bug.cgi?id=1038
- d-bugmail puremagic.com (9/9) Mar 11 2007 http://d.puremagic.com/issues/show_bug.cgi?id=1038
http://d.puremagic.com/issues/show_bug.cgi?id=1038 Summary: explicit class cast breakage in 1.007 Product: D Version: 1.007 Platform: PC OS/Version: All Status: NEW Severity: critical Priority: P2 Component: DMD AssignedTo: bugzilla digitalmars.com ReportedBy: default_357-line yahoo.de Consider the following code: import std.stdio; class A { } class B : A { } void main() { A test=new B; writefln("Test is ", test.toString); A test_2=cast(A)(new B); writefln("Test 2 is ", test_2.toString); } What we would expect to see is "test7.B" twice. However, what we see is "test7.B" and "test7.A", which of course completely breaks polymorphism. The error doesn't appear on 1.005, so it was introduced either in '006 or '007. Greetings --downs --
Mar 08 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1038 fvbommel wxs.nl changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |wrong-code ------- Comment #1 from fvbommel wxs.nl 2007-03-08 05:20 ------- Judging by the disassembled code, it appears "cast(A)(new B)"is compiled as if it was "new A", it passes the ClassInfo for A instead of that for B to _d_newclass... By the way, the same thing happens in GDC[1], so it's most likely an error in the front-end. [1]: (gdc 0.23, using dmd 1.007), the x86-64 Linux binary from sourceforge. --
Mar 08 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1038 ------- Comment #2 from thomas-dloop kuehne.cn 2007-03-11 06:20 ------- Added to DStress as http://dstress.kuehne.cn/run/c/cast_34_A.d http://dstress.kuehne.cn/run/c/cast_34_B.d --
Mar 11 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1038 thomas-dloop kuehne.cn changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED ------- Comment #3 from thomas-dloop kuehne.cn 2007-03-12 01:23 ------- Fixed in DMD-1.009 --
Mar 11 2007