File tree Expand file tree Collapse file tree 3 files changed +24
-0
lines changed Expand file tree Collapse file tree 3 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -1977,7 +1977,12 @@ void checkObErrors(ref ObState obstate)
1977
1977
else if (isReadonlyPtr(v))
1978
1978
pvs.state = PtrState.Readonly;
1979
1979
else
1980
+ {
1981
+ if (pvs.state == PtrState.Owner && v.type.hasPointersToMutableFields())
1982
+ v.error(e.loc, " assigning to Owner without disposing of owned value" );
1983
+
1980
1984
pvs.state = PtrState.Owner;
1985
+ }
1981
1986
pvs.deps.zero();
1982
1987
1983
1988
EscapeByResults er;
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ fail_compilation/fob1.d(104): Error: variable `fob1.foo1.p` is returned but is U
17
17
18
18
/* TEST_OUTPUT:
19
19
---
20
+ fail_compilation/fob1.d(204): Error: variable `fob1.foo2.p` assigning to Owner without disposing of owned value
20
21
fail_compilation/fob1.d(203): Error: variable `fob1.foo2.p` is left dangling at return
21
22
---
22
23
*/
Original file line number Diff line number Diff line change @@ -175,3 +175,21 @@ void free7(int*);
175
175
{
176
176
free7(p);
177
177
}
178
+
179
+ /* TEST_OUTPUT:
180
+ ---
181
+ fail_compilation/fob2.d(807): Error: variable `fob2.test8.p` assigning to Owner without disposing of owned value
182
+ ---
183
+ */
184
+
185
+ #line 800
186
+
187
+ int * malloc8 ();
188
+ void free8 (int * );
189
+
190
+ @live void test8()
191
+ {
192
+ int * p = malloc8();
193
+ p = malloc8(); // error here
194
+ free8(p);
195
+ }
You can’t perform that action at this time.
0 commit comments