Can we just have struct inheritence already?

Jonathan M Davis newsgroup.d at jmdavisprog.com
Tue Jun 11 05:20:34 UTC 2019


On Monday, June 10, 2019 6:30:27 PM MDT Walter Bright via Digitalmars-d 
wrote:
> On 6/10/2019 3:56 PM, Manu wrote:
> > Uninitialised data, which is guaranteed to have no valid state, and
> > has absolutely no chance of proper program execution under any
> > circumstance, and may even be leaking internal/private state(!), is
> > not safe. You can't convince me otherwise.
>
> It is memory safe. It's a fact, not an opinion.
>
> If you want @safe to mean "no undefined behavior", that is a valid
> opinion, but that is not what @safe in D is currently defined as. It is
> currently defined as "memory safe". If you can find a case where an int
> with garbage in it can cause memory corruption in @safe code, that would
> indeed be a bug in D.

It was my understanding that having no undefined behavior was required to be
able to guarantee memory safety, since without that, the compiler could
potentially reorder or optimize code in a way that violated memory safety
(because undefined behavior lets the compiler do pretty much whatever it
wants with that piece of code). Regardless of whether that's true or not
however, the spec _does_ state that @safe functions don't have undefined
behavior. In fact, surpisingly, the primary section on @safe functions says
that without saying anything about memory safety:

https://dlang.org/spec/function.html#function-safety

- Jonathan M Davis





More information about the Digitalmars-d mailing list