www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 18823] New: null is not shared as far as templates go

https://issues.dlang.org/show_bug.cgi?id=18823

          Issue ID: 18823
           Summary: null is not shared as far as templates go
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: dmitry.olsh gmail.com

Tested on DMD 2.079.

void main(){
    // failure: template testme.takePointer cannot deduce function from
argument types 
    //!()(typeof(null)), candidates are: ...
    takePointer(null); 
    takePointer2(null);
}

void takePointer(T)(shared(T)* ptr){}

void takePointer2(T)(shared T* ptr){}

// same problem in the "real" world
void inPhobos(){
    import core.atomic;
    shared Object abc;
    shared Object b = new Object;
    cas(&abc, b, null); // doesn't compile
    cas(&abc, b, cast(shared)null); // this compiles
    atomicStore(abc, null); // this compiles as well
}

--
May 04 2018