GC and void[N] in struct
nkm1
t4nk074 at openmailbox.org
Mon Aug 6 19:17:58 UTC 2018
On Monday, 6 August 2018 at 18:22:24 UTC, vit wrote:
> Hello,
> I have this struct:
>
> struct S{
> uint kind;
> void[N] data_;
>
> }
>
> Instances of struct S are allocated by standard GC new and
> S.data_ can contain pointers/ranges to GC allocated data.
> If is GC disabled then program run fine. But when is GC
> enabled then it fail randomly.
>
> If the definition of S look like this:
>
> struct S{
> void[N] data_;
> uint kind;
> }
>
> then program run fine with GC.enable.
>
> Whats the problem? Something with alignment?
Probably. Try something like:
struct S
{
uint kind;
align((void *).alignof) void[N] data_;
}
And see if it solves the problem.
More information about the Digitalmars-d-learn
mailing list