Returning a reference to be manipulated

kdevel kdevel at vogtner.de
Sat Apr 15 21:00:01 UTC 2023


On Saturday, 15 April 2023 at 15:50:18 UTC, Dennis wrote:
> [...]
> care about the type / mutability of the pointer.

Returning `i`'s address in a long does not trigger the escape 
detector:

```
long foo (long s, return ref int i)
{
    s = cast (long) &i;
    return s;
}

auto bar ()
{
    int i;
    long s;
    return foo (s, i);
}
```

dmd compiles this without complaints.



More information about the Digitalmars-d-learn mailing list