Questions tagged [memory-safety]

For questions about memory safety features in programming languages, to prevent misuse of memory and related errors.

Filter by
Sorted by
Tagged with
5 votes
4 answers

Creating a new language with Rust without Garbage Collection?

I am new to language development. I am aware of Rust's ownership model that builds programs in a way that does not need garbage collection. So if I am to build a new programming language using safe ...
M4X_'s user avatar
  • 153
19 votes
10 answers

Why would accessing uninitialized memory necessarily be undefined behavior?

In C, accessing any indeterminate/uninitialized memory is undefined behavior, period. Even in the case that the type in question is guaranteed to have no trap representations, such as ...
user16217248's user avatar
  • 7,535
3 votes
1 answer

Memory layout from a native class

I think there are languages where most of the standard library is written in themselves, however with most things marked as native or ...
Hydroper's user avatar
  • 909
-1 votes
1 answer

Creating a high level language that transpiles to rust

I really like what Rust brings to the table, but I find it very difficult to work with if I am not really working on apps that require absolute speed and the lower-levelness e.g. specifying int sizes, ...
Ong Teck Wu's user avatar
11 votes
4 answers

Can a language allow raw pointer dereferencing while preserving memory safety?

In Rust, creating a raw pointer is allowed in safe code (i.e. outside of unsafe blocks), but then dereferencing it is unsafe: ...
mousetail's user avatar
  • 8,111
2 votes
4 answers

Approaches for implementing weak references

How can weak references (weakrefs) be implemented, and how do the different approaches compare? The most important considerations for implementing weakrefs are: Safety ─ a weakref shouldn't allow ...
kaya3's user avatar
  • 17.3k
14 votes
2 answers

Could ownership be inferred?

Rust famously has the concept of ownership vs. borrowing as part of its type system. This allows some level of automatic memory management ─ that is, heap allocations are freed when their owner goes ...
kaya3's user avatar
  • 17.3k
12 votes
3 answers

Is it possible to extend C to have the Rust concept of ownership for memory safety?

Rust has a number of memory safety features. Is it possible to extend or enhance C or C++ to also provide similar memory safety features instead of using workarounds such as the Valgrind tool suite?
James Risner's user avatar