www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 686] New: [Regression] opCast of a struct or union is called in nonsensical circumstances

reply d-bugmail puremagic.com writes:
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.


-- 
Dec 13 2006
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=686


bugzilla digitalmars.com changed:

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





Fixed DMD 0.178


-- 
Dec 27 2006
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=686






Added to DStress as
http://dstress.kuehne.cn/run/o/opCast_04_A.d
http://dstress.kuehne.cn/run/o/opCast_04_B.d


-- 
Dec 30 2006