[Issue 20634] New: @safe forces bounds checking on newly allocated array when using .ptr

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Mar 4 03:38:04 UTC 2020


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

          Issue ID: 20634
           Summary: @safe forces bounds checking on newly allocated array
                    when using .ptr
           Product: D
           Version: D2
          Hardware: x86
                OS: Mac OS X
            Status: NEW
          Keywords: rejects-valid
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: pro.mathias.lang at gmail.com

```
void main () @safe
{
    auto ptr = [ 42 ].ptr;
}
```

This errors out, even tho it is perfectly @safe.

```
foo.d(3): Error: [42].ptr cannot be used in @safe code, use &[42][0] instead
```

DMD v2.090.1

--


More information about the Digitalmars-d-bugs mailing list