← Back to index
|
Original Bugzilla link
Bug 17368 – [DIP1000] scope T** implicit convertion to scope T* allow to escape pointer
Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2017-05-04T08:57:00Z
Last change time
2017-05-04T09:26:35Z
Assigned to
nobody
Creator
mathias.lang
Comments
Comment #0
by mathias.lang — 2017-05-04T08:57:55Z
Code below: ``` void main () @safe { getPtr(); } void getPtr () @safe { int* ptr2; bar(&ptr2); assert(ptr2 !is null, "Oops, I have a pointer to bar.value"); } void bar (scope int** ptr2) @safe { int value; foo(ptr2, &value); } // Needs to be 'return scope' so that the compiler believes 'ptr1' has longer lifetime thatn 'ptr2' void foo (scope int** ptr2, scope int* ptr1) @safe { foobar(*ptr2, ptr1); } int* foobar (scope int* p1, return scope int* p2) @safe { p1 = p2; return p2; } ```
Comment #1
by mathias.lang — 2017-05-04T09:26:35Z
My bad, this example is totally wrong.