malloc error when trying to assign the returned pointer to a struct field
Basile B.
b2.temp at gmx.com
Fri Sep 8 19:48:33 UTC 2023
On Friday, 8 September 2023 at 18:59:21 UTC, rempas wrote:
> On Friday, 8 September 2023 at 16:02:36 UTC, Basile B. wrote:
>>
>> Could this be a problem of copy construction ?
>
> I don't think so.
My idea was that if you dont have defined a copy constructor and
if an instance is assigned to another, then that other instance
share the same pointer, which can cause memory errors.
To eliminate that risk and to detect where default post-blitting
may happen you can add
```d
@disable this(this);
```
to the struct.
More information about the Digitalmars-d-learn
mailing list