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

--- Comment #0 from Nick Treleaven <> 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

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to