[Issue 20989] New: Checking array.ptr causes safety error with -checkaction=context
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Jun 28 19:57:42 UTC 2020
https://issues.dlang.org/show_bug.cgi?id=20989
Issue ID: 20989
Summary: Checking array.ptr causes safety error with
-checkaction=context
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: minor
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: moonlightsentinel at disroot.org
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
========================================
--
More information about the Digitalmars-d-bugs
mailing list