Thread overview
[Issue 686] New: [Regression] opCast of a struct or union is called in nonsensical circumstances
Dec 13, 2006
d-bugmail
Dec 27, 2006
d-bugmail
Dec 30, 2006
d-bugmail
December 13, 2006
http://d.puremagic.com/issues/show_bug.cgi?id=686

           Summary: [Regression] opCast of a struct or union is called in
                    nonsensical circumstances
           Product: D
           Version: 0.177
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla@digitalmars.com
        ReportedBy: smjg@iname.com


This used to work.  But now, it's broken the bit array/pointer types in my utility library.

----------
struct Qwert {
    Yuiop opCast() {
        return Yuiop.init;
    }
}

struct Yuiop {
    Qwert asdfg() {
        return Qwert.init;
    }

    void hjkl() {
        Qwert zxcvb = asdfg();  // line 13
    }
}
----------
opCast_struct.d(13): Error: cannot implicitly convert expression
(((this.asdfg)().opCast)()) of type Yuiop to Qwert
----------

There's absolutely no reason that it should be trying to call Qwert.opCast. adsfg() is already of type qwert; even if it wasn't, this wouldn't make sense since "Overloading the cast operator does not affect implicit casts, it only applies to explicit casts."

If Qwert.opCast is removed, the code compiles without error.


-- 

December 27, 2006
http://d.puremagic.com/issues/show_bug.cgi?id=686


bugzilla@digitalmars.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED




------- Comment #1 from bugzilla@digitalmars.com  2006-12-27 02:04 -------
Fixed DMD 0.178


-- 

December 30, 2006
http://d.puremagic.com/issues/show_bug.cgi?id=686





------- Comment #2 from thomas-dloop@kuehne.cn  2006-12-30 09:48 -------
Added to DStress as http://dstress.kuehne.cn/run/o/opCast_04_A.d http://dstress.kuehne.cn/run/o/opCast_04_B.d


--