D.gnu - [Bug 164] New: Array assignment doesn't call destructors
- via D.gnu (40/40) Nov 04 2014 Date: Wed, 5 Nov 2014 06:29:34 +0000
Date: Wed, 5 Nov 2014 06:29:34 +0000 MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" http://bugzilla.gdcproject.org/show_bug.cgi?id=164 Bug ID: 164 Summary: Array assignment doesn't call destructors Product: GDC Version: 4.9.x Hardware: All OS: All Status: NEW Severity: normal Priority: Normal Component: gdc Assignee: ibuclaw gdcproject.org Reporter: shachar shemesh.biz Created attachment 78 --> http://bugzilla.gdcproject.org/attachment.cgi?id=78&action=edit Smart pointer example Please consider the RAII smart pointer implementation attached. The smart pointer is implemented following the rule of three. The unit test, however, fails on line 137. When a static array is being initialized over with the array's init, GDC neither calls the destructors nor uses opAssign, causing a resource leak. This problem also exists in DMD, and was filed there (see https://issues.dlang.org/show_bug.cgi?id=13661). Changing the static if at line 108 to false, we reset the array by using array iteration to assign to the individual elements. This variant passes on DMD, but fails on GDC. Lastly, changing the static if at line 110 to false, we perform an actual loop over the elements. This passes on all compilers. To the best of my understanding: array type a; the following three lines should be completely equivalent: a = a.init; a = type.init; foreach(ref i; a) i = type.init; Shachar -- You are receiving this mail because: You are watching all bug changes.
Nov 04 2014