| > but it's still possible to use memory incorrectly Only by misusing unsafe. Using it in regular programs actually isn't that necessary. In languages like C you have unsafe code almost in every line. > My understanding is that a memory bug is when you use memory in an unintended way Memory safety rules are more strict and formalized than you think. Memory safety issues are typically reading uninitialized memory (or strictly speaking changing observable behavior based on contents of uninitialized memory), reading/writing memory after it have been freed (free/delete call or out-of-scope going for local variables), concurrent unsynchronized memory access. > No compiler or tool can make sure you don't write to or read deallocated memory I am author of a programming language, where you can't write to or read deallocated memory, unless you misusing unsafe. > no compiler can read your thoughts But many languages more complex than C have powerful features allowing telling the compiler your about intents. At least partially. > Memory allocation is relative. In a sense, no program that runs under an operating system can use deallocated memory You are mixing two different concepts. One is memory model of the abstract machine defined by the specification of a language and other is the OS processes model. They have much in common, but there are a lot of differences. > So again, everything is safe if you use it as intended Such mindset is considered harmful, since it provides an excuse to use languages where making mistakes is easy (like C). |