www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 20656] New: cannot compile live function without

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

          Issue ID: 20656
           Summary: cannot compile live function without -preview=dip1021
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: kubo39 gmail.com

Code:

---
import core.stdc.stdlib : free, malloc;

 live
void main()
{
    auto p = malloc(1);
    free(p);
    free(p);
}
---

Output:

---
$ dmd bugfix.d
bugfix.d(8): Error: variable bugfix.main.p has undefined state and cannot be
read
bugfix.d(8): Error: variable bugfix.main.p is not Owner, cannot consume its
value
---

--
Mar 09