dip1000 and preview in combine to cause extra safety errors

Dukc ajieskola at gmail.com
Wed Jun 8 20:49:46 UTC 2022


On Wednesday, 8 June 2022 at 19:02:53 UTC, Steven Schveighoffer 
wrote:
> D already doesn't allow returning a pointer to stack data, even 
> in `@system` code. Doesn't this also qualify?
>
> -Steve

D does allow it, just not directly:

```D
// error
int* escape(int arg){return &arg;}

// ok
int* escape(int arg)
{ auto temp = &arg;
   return temp;
}
```

The philosophy is to force to be explicit in the simplest cases 
that are almost always errors, but not trying to seriously 
prevent the escape.


More information about the Digitalmars-d mailing list