[Issue 19873] New: unittest should be by default @system even with -preview=dip1000

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue May 14 18:08:47 UTC 2019


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

          Issue ID: 19873
           Summary: unittest should be by default @system even with
                    -preview=dip1000
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: greeenify at gmail.com

---
@system unittest
{
    int i;
    int* p = &i;
    int[]  slice = [0, 1, 2, 3, 4];
    int[5] arr   = [0, 1, 2, 3, 4];
    int*[]  slicep = [p];
}
---

Compiles fine with -unittest -preview=dip1000.
Remove @system:

---
unittest
{
    int i;
    int* p = &i;
    int[]  slice = [0, 1, 2, 3, 4];
    int[5] arr   = [0, 1, 2, 3, 4];
    int*[]  slicep = [p];
}
---

$ dmd -unittest -preview=dip1000 foo.d

And now it errors:

---
foo.d(7): Error: scope variable p may not be copied into allocated memory
---

--


More information about the Digitalmars-d-bugs mailing list