[Issue 5747] New: cannot cast away shared if opCast defined

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Mar 17 06:39:20 PDT 2011


http://d.puremagic.com/issues/show_bug.cgi?id=5747

           Summary: cannot cast away shared if opCast defined
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: ntrel-public at yahoo.co.uk


--- Comment #0 from Nick Treleaven <ntrel-public at yahoo.co.uk> 2011-03-17 06:36:07 PDT ---
struct S {
    int opCast() {return cast(int)this;}
}

shared S s;

void main() {
    auto u = cast(S)s;
}

shared.d(8): Error: function shared.S.opCast () is not callable using argument
types ()
shared.d(8): Error: cannot implicitly convert expression (s.opCast()) of type
int to S

Also happens if opCast returns other types, e.g. void[], etc.
Removing 'shared' compiles OK. Tested with dmd v2.051.

This code adapted from a newsgroup post about casting away shared from
BitArray:
http://www.digitalmars.com/pnews/read.php?server=news.digitalmars.com&group=digitalmars.D&artnum=132066

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list