www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21459] New: live owned pointer still alive at the end of

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

          Issue ID: 21459
           Summary:  live owned pointer still alive at the end of  live
                    function not detected
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: witold.baryluk+d gmail.com

```
public:

 live int square(scope const int* num);

 live int kwadrat(int* num) {
    return square(num);
}
```

and

```
public:

 live int square(scope const int* num) {
    return *num * *num;
}

 live int kwadrat(int* num) {
    return square(num);
}

```

should not compile, and emit the error:

<source>(5): Error: variable `example.kwadrat.num` is left dangling at return


But they do compile, and no error is emitted.

DMD 2.094.2 on Linux.

This appears to be a regression. It worked correctly in 2.091, and stopped
working correctly in 2.092.

--
Dec 07 2020