struct M { int i; S*[100] s; } struct S { M* mp; bool x; } S* add(A...)() { alias m = A[0]; __gshared s = S(&m,A[1..$]); m.s[m.i++] = &s; return &s; } void main(){ __gshared M m = M(0); __gshared S s = S(&m, false); m.s[m.i++] = &s; auto p = add!(m, true); }