[Issue 17769] New: dmd accepts conversion from shared(int)* to int* when value comes from method

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sun Aug 20 11:09:10 PDT 2017


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 at puremagic.com
          Reporter: ag0aep6g at 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
----

--


More information about the Digitalmars-d-bugs mailing list