On 22 May 2018 at 06:44, Steven Schveighoffer via Digitalmars-d
<digitalmars-d@puremagic.com> wrote:
> On 5/22/18 1:01 AM, Manu wrote:
>>
>> On 21 May 2018 at 15:51, Steven Schveighoffer via Digitalmars-d
>> <digitalmars-d@puremagic.com> wrote:
>>>
>>> On 5/21/18 6:37 PM, Manu wrote:
>>>>
>>>>
>>>> On 21 May 2018 at 15:29, Steven Schveighoffer via Digitalmars-d
>>>> <digitalmars-d@puremagic.com> wrote:
>>>>>
>>>>>
>>>>> Uninitialized, but allocated and usable. The difference between this
>>>>> and
>>>>> delete is that delete is going to unallocate that memory. The next time
>>>>> it's
>>>>> allocated, it will be overwritten with an init pattern for the new
>>>>> type.
>>>>>
>>>>> Basically, in D when you have access to memory, it should be in a valid
>>>>> state.
>>>>
>>>>
>>>>
>>>> Why is it reasonable to expect that the buffer after `destroy()`
>>>> should be 'valid'?
>>>> Who's to say that the init state is 'valid'?
>>>
>>>
>>>
>>> It's valid in that it's not garbage, and that it's not full of dangling
>>> pointers.
>>
>>
>> Ah! Dangling pointers... that might conservatively retain garbage.
>> That's a good reason.
>
>
> Well, I was thinking more along the lines of accessing memory that is no
> longer valid :) A destructor can, for instance, free C malloced memory.

The memory post-destruction is invalid... nobody will access it.
Accessing it should be undefined behaviour until such a time as the
memory is re-constructed with a new instance...

Reply via email to