Bug 20989 – Checking array.ptr causes safety error with -checkaction=context

Status
RESOLVED
Resolution
FIXED
Severity
minor
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2020-06-28T19:57:42Z
Last change time
2020-07-09T21:25:59Z
Keywords
pull
Assigned to
No Owner
Creator
moonlightsentinel

Comments

Comment #0 by moonlightsentinel — 2020-06-28T19:57:42Z
The following code fails to compile with -checkaction=context: ======================================== void main() @safe { uint[] arr = [1, 2, 3]; assert(!arr.ptr); assert(arr.ptr is arr.ptr); } ======================================== dmd --checkaction=context safety.d safety.d(6): Error: arr.ptr cannot be used in @safe code, use &arr[0] instead safety.d(7): Error: arr.ptr cannot be used in @safe code, use &arr[0] instead safety.d(7): Error: arr.ptr cannot be used in @safe code, use &arr[0] instead ========================================
Comment #1 by dlang-bot — 2020-06-28T20:12:27Z
@MoonlightSentinel created dlang/dmd pull request #11337 "Fix Issue 20989 - Checking array.ptr causes safety error ..." fixing this issue: - Fix Issue 20989 - Checking array.ptr causes safety error ... ... with -checkaction=context. Explicity flag `DotIdExpressions` as `noderef` because `_d_assert_fail` will not dereference the pointer and thus make the call `@safe`. https://github.com/dlang/dmd/pull/11337
Comment #2 by dlang-bot — 2020-07-04T12:00:15Z
dlang/dmd pull request #11337 "Fix Issue 20989 - Checking array.ptr causes safety error ..." was merged into stable: - 8591c1da46903cc97c13efb1dbe79a4e7f1872ab by MoonlightSentinel: Fix Issue 20989 - Checking array.ptr causes safety error ... ... with -checkaction=context. Explicity flag `DotIdExpressions` as `noderef` because `_d_assert_fail` will not dereference the pointer and thus make the call `@safe`. https://github.com/dlang/dmd/pull/11337
Comment #3 by dlang-bot — 2020-07-09T21:25:59Z
dlang/dmd pull request #11400 "merge stable" was merged into master: - 95be29f324c6eb655ff93807102120d7d5c80ee5 by MoonlightSentinel: Fix Issue 20989 - Checking array.ptr causes safety error ... ... with -checkaction=context. Explicity flag `DotIdExpressions` as `noderef` because `_d_assert_fail` will not dereference the pointer and thus make the call `@safe`. https://github.com/dlang/dmd/pull/11400