Memory safe in D - cppfront/C++

Nick Treleaven nick at geany.org
Thu Apr 11 16:25:30 UTC 2024


On Thursday, 11 April 2024 at 16:19:52 UTC, Nick Treleaven wrote:
> Each point where a pointer variable is modified, the compiler 
> tracks what possible things it could point to, e.g. local data.

It tracks anything in the scope of the current function that the 
pointer could point to, at each statement.

> For the latter, when the local data goes out of scope, if the 
> pointer hasn't been overwritten, then it is known to be 
> pointing to invalid data and any subsequent dereference is 
> flagged at compile-time.

What I meant was if there is a dereference of a pointer that *may 
have been* (according to the limited analysis) assigned the 
address of a local that has gone out of scope, that dereference 
gets flagged at compile-time. Even though at runtime it may never 
actually have that address.


More information about the Digitalmars-d mailing list