www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 17769] New: dmd accepts conversion from shared(int)* to int*

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

          Issue ID: 17769
           Summary: dmd accepts conversion from shared(int)* to int* when
                    value comes from method
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Keywords: accepts-invalid
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: ag0aep6g gmail.com

----
struct S()
{
    shared(int)* method() { return ptr; }
    shared(int)* ptr;
}

void main()
{
    S!() s;
    int* foo = s.method(); /* accepted; should be rejected */
}
----

These variations are correctly rejected:

----
    auto foo = s.method();
    int* bar = foo; // rejected as expected
    int* baz = s.ptr; // ditto
----

--
Aug 20