2 // https://issues.dlang.org/show_bug.cgi?id=3463
3 // https://issues.dlang.org/show_bug.cgi?id=4358
4 // https://issues.dlang.org/show_bug.cgi?id=9094
5 // https://issues.dlang.org/show_bug.cgi?id=13801
6 // https://issues.dlang.org/show_bug.cgi?id=18900
10 import core
.stdc
.stdio
;
69 // compiling with -gx should help eliminating false pointers on the stack
70 Roots
makeFalsePointers()
72 roots
.c
.val
= cast(size_t
) cast(void*) roots
.c
.next
;
74 roots
.s
.val
= cast(size_t
) cast(void*) roots
.s
.next
;
76 roots
.l
.data
[7] = cast(size_t
) cast(void*) roots
.l
.node
;
79 return Roots(null, null, null); // try to spill register contents
84 iroots
= cast(size_t
)roots
;
87 return Roots(null, null, null); // try to spill register contents
90 // compiling with -gx should help eliminating false pointers on the stack
91 void verifyFalsePointers()
94 if (C
.dtors
< 1) printf ("False pointers? C.dtors = %d, 1 expected\n", C
.dtors
);
96 if (S
.dtors
< 2) printf ("False pointers? S.dtors = %d, 2 expected\n", S
.dtors
);
100 extern(C
) __gshared string
[] rt_options
= [ "gcopt=gc:precise", "scanDataSeg=precise" ];
104 GC
.collect(); // cleanup from unittests
107 GC
.collect(); // should collect nothing
111 GC
.collect(); // should collect roots.c.next, roots.s.next and roots.l.node
112 verifyFalsePointers();
115 GC
.collect(); // should collect all
117 version(Windows
) // precise DATA scanning only implemented on Windows
119 assert(C
.dtors
<= 2);
120 if (C
.dtors
< 2) printf ("False DATA pointers? C.dtors = %d, 2 expected\n", C
.dtors
);
121 assert(S
.dtors
<= 3);
122 if (S
.dtors
< 3) printf ("False DATA pointers? S.dtors = %d, 2 expected\n", S
.dtors
);
123 assert(L
.dtors
<= 1);
124 if (L
.dtors
< 1) printf ("False DATA pointers? L.dtors = %d, 1 expected\n", L
.dtors
);