Memory safe in D

Walter Bright newshound2 at digitalmars.com
Tue Mar 12 03:19:54 UTC 2024


All a seg fault is is the hardware detecting the fault.

Consider an array overflow:

```
int test(int[] a)
{
     return a[100];
}
```
There is no way in general to detect an array overflow here, so there is a 
runtime check. If the check fails, a fatal array overflow exception is generated.

I'm pretty sure Rust does the same thing for array overflows.

A seg fault is no different, it's just the hardware doing the check for you, so 
it doesn't cost you any extra code or speed.


More information about the Digitalmars-d mailing list